This Question is Answered 

    How Can I Create A Procedur For Truncate The Table? I Want To Use This Procedur In Information For Truncate The Table Before Load The Target.

    asked 2 years ago

    Can't find what you're looking for?

    Ask a Question, Get an Answer ASAP


    Answers


    Yes, you can truncate any table using TRUNCATE TABLE command using in procedure. Following are the two procedure which can truncate a single table or desired even all tables in schema.

    Truncating a single table.

    DECLARE
    vtable varchar2:=table_name;
    BEGIN
    TRUNCATE_TABLE vtable;
    -- table will be truncate now here u can perform some desired action.
    END;

    Truncating multiple tables in schema

    DECLARE
    vschema varchar2:=scott;

    BEGIN
    FOR V1 IN (SELECT ' TRUNCATE TABLE '||vschema||'.'||table_name||' ;' as vtrunc from all_tables WHERE user = vschema) LOOP

    EXECUTE IMMEDIATE v1.vtrunc;
    END LOOP;
    --All table which will retrive in select statement will be truncated.
    END;

    answered 2 years ago   

    New Comment

    1000 words left


      What is Blurtit ?

      Ask questions on any topic, get great answers from real people for FREE. Blurtit has hundreds of thousand of members so your sure to get the answer your looking for.

      Ask a Question.