DDL commands of SQL
DDL commands of SQL
► Example:
1. TRUNCATE TABLE EMP;
2. TRUNCATE TABLE DEPARTMENT;
DROP COMMAND
► The DROP command is used to remove an object
from the database.
► If u drop a table, all the rows in the table is deleted
and the table structure is removed from the
database.
► Once a table is dropped we cannot get it back, so be
careful while using drop command.
► When a table is dropped all the references to the
DROP COMMAND
► Syntax:
DROP TABLE TABLE_NAME;
► Example:
DROP TABLE EMP;
DROP TABLE DEPARTMENT;
Difference
TRUNCATE DROP
Truncate command removes all Drop command removes all records
records from the specified table, but from the table along with the table
keeps structure of the table intact. structure and puts it in recycle bin.
The records once deleted with The table removed with the drop
truncate command cannot be command can be recovered from the
recovered with the help of rollback. recycle bin with the help of flashback
command.
Difference
TRUNCATE DELETE
Truncate command removes all Delete command can delete one
records from the specified table. or more records from the table.
The records once deleted with The records once deleted with
truncate command cannot be delete command can be
recovered with the help of recovered with the help of
rollback. rollback.