Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Difference between DELETE and TRUNCATE commands?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 105
    Comment on it

    Delete command in SQL removes the ROW based on the condition provided with the WHERE clause, if no WHERE clause is provided it deletes all the row from the table.

    Syntax for delete command:

    DELETE FROM table_name WHERE column_name='value';

    Truncate command will removes all the rows from the table at one time, and there will be no data left on the table after Truncate command is called.

    Syntax for truncate command:

     TRUNCATE TABLE table_name;

    Some other differences between DELETE and TRUNCATE are:

    1. DELETE commands removes one row at a time whereas TRUNCATE removes all the rows from the table.
    2. With DELETE command you can retain Identity counter whereas TRUNCATE resets the Identity counter.
    3. DELETE command activate triggers whereas TRUNCATE cannot activate triggers
    4. DELETE is a DML command wheras TRUNCATE is a DDL command.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: