1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

What type of trigger will be fired after truncating a table

Discussion in 'SQL PL/SQL' started by venu57, Aug 4, 2014.

  1. venu57

    venu57 Active Member

    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    100
    Location:
    Bangalore
    Hi Friends,

    I have a table "Sample". I truncated it. What type of Trigger will be fired?

    According to my knowledge, trigger applies for INSERT/UPDATE/DELETE.

    If you guys know about that Please let me know.

    Regards
    Venu
     
  2. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Hi.
    Truncate Table

     
    venkateshguru likes this.
  3. venu57

    venu57 Active Member

    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    100
    Location:
    Bangalore
    Given information is valuable, but my question is when i truncated the table, what type of trigger could be fired ??
     
  4. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    The trigger aren't executed....
    For example :

    Code (SQL):


    DROP TABLE simple_tab purge;
    CREATE TABLE simple_tab
    (id INT PRIMARY KEY,
     y  varchar2(100)
    );


    INSERT INTO simple_tab
    SELECT
        level,
        dbms_random.string('x',100)
    FROM dual
    CONNECT BY level <= 10001;
    commit;

    CREATE OR REPLACE TRIGGER trg_simple_tab
    after INSERT OR UPDATE OR DELETE
    ON  simple_tab
    FOR each ROW
    BEGIN
        raise_application_error(-20001,'Is worked!');
    END;
    /

    TRUNCATE TABLE simple_tab;



    SQL>
     
    TABLE dropped
     
    TABLE created
     
    10001 ROWS inserted
     
    Commit complete
     
    TRIGGER created
     
    TABLE truncated
     
    SQL>

     
     
  5. ocprep

    ocprep Forum Advisor

    Messages:
    277
    Likes Received:
    76
    Trophy Points:
    410
    Location:
    Orlando, Florida
    Specifically -- triggers fire when DML commands are executed.
    TRUNCATE is a DDL command and therefore does not have an associated trigger event.
     
  6. venu57

    venu57 Active Member

    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    100
    Location:
    Bangalore
    Thanks you friends!!!! Thank you for your valuable answers....