• September 29, 2014
  • SQL
  • Comments Off on SQL TRUNCATE Table

SQL TRUNCATE Table

The TRUNCATE TABLE command is used to remove the all rows from an existing table.

Syntax: TRUNCATE TABLE tableName; 

Example:

TRUNCATE TABLE EMPLOYEE;

Output:

Table truncated.

Difference between TRUNCATE, DELETE and DROP commands:

The DELETE statement is used to delete or remove all the rows from the table. We can use where clause to delete some specific rows. We can roll back the DELETE operation. DELETE is slower than TRUCATE. It is a DML command. Table structure will not be lost.

The TRUNCATE statement is used to remove the all rows from an existing table. We can’t roll back the TRUNCATE operation. TRUCATE is faster than DELETE. It is a DDL command. Table structure will not be lost.

The DROP TABLE statement is used to delete an existing table definition, indexes, constraints, access privileges and all associated data. We can’t roll back the DROP operation. It is DDL command. Table structure will be lost.

 
Next Topic: SQL CONSTRAINTS with example.
Previous Topic: SQL DELETE from table with example.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.

 


Comments are closed.