TRUNCATE
- TRUNCATE comes under DDL(Data Definition Language).
- TRUNCATE removes only rows from the table but the structure of the table remains same.
- Data can not be roll backed if we use "TRUNCATE" command to delete data.
- Can not use WHERE clause.
TRUNCATE TABLE statement is usually used to delete all the records inside a table.
The TRUNCATE TABLE Statement
When we want to delete all the records inside a table then, use the TRUNCATE TABLE statement.
Syntax:
TRUNCATE TABLE table_name;
Example:
The below statement deletes all the records of "user" table:
TRUNCATE TABLE user;
DROP
- DROP comes under DDL(Data Definition Language).
- It removes whole table (including table structure) from the database.
- The data cannot be roll backed if the table is dropped by 'DROP' command.
Syntax:
DROP TABLE table_name;
Example:
The below statement drops the "user" table from the database:
DROP TABLE user;
Hope this will help you :)
0 Comment(s)