Question

In: Computer Science

Explain the similarities and differences between Drop (a table), Truncate (the data), and Delete (the data).

Explain the similarities and differences between Drop (a table), Truncate (the data), and Delete (the data).

Solutions

Expert Solution

Difference between DELETE, DROP and TRUNCATE

1. DELETE : Delete is Data Manipulation Language statement which is used used only for deleting data from a table, not to remove the table from the database.

Delete Statement does not change any property of database.

With the help of “DELETE” command we can either delete all the rows in one go or can delete row one by one. i.e., we can use it as per the requirement or the condition using Where clause.

It is comparatively slower than TRUNCATE cmd.

This operation uses all Delete triggers.

Syntax : If we want to delete all the rows of the table:

DELETE from table_name; 

Syntax: If we want to delete the row of the table as per the condition then we use WHERE clause,

DELETE from table_name WHERE condition; 
You can use the “ROLLBACK” command to restore the tuple.

2. DROP : Drop is Data Definition Language Statement.

The Drop command removes the table from the database.

With the help of “DROP” command we can drop (delete) the whole structure in one go i.e. it removes the named elements of the schema. By using this command the the table structure and data both is deleted.

Syntax : If we want to drop the table:

DROP table table_name ;  
You can’t restore the table by using the “ROLLBACK” command.

3. TRUNCATE : It is also a Data Definition Language Command (DDL).

It is use to delete all the rows of a table in one go.

With the help of “TRUNCATE” command we can’t delete the single row as here WHERE clause is not used. By using this command the existence of all the rows of the table is lost.

It is comparatively faster than delete command as it deletes all the rows fastly.

Syntax If we want to use truncate :

TRUNCATE table_name;  

You can’t restore the rows of the table by using the “ROLLBACK” command.

Similarity between DELETE, DROP and TRUNCATE

Delete, Drop and Truncate all delete data of table.


Related Solutions

What are the similarities and differences between database, data warehouse, and data mining?
What are the similarities and differences between database, data warehouse, and data mining?
explain the differences and similarities between prokaryoutes and eukaryotic cells.
explain the differences and similarities between prokaryoutes and eukaryotic cells.
explain the differences and similarities between classical and relativistic Electrodynamics.
explain the differences and similarities between classical and relativistic Electrodynamics.
explain the differences and similarities between classical and relativistic mechanics.
explain the differences and similarities between classical and relativistic mechanics.
Make a table or list of the major similarities & differences between the Moon & Mercury,...
Make a table or list of the major similarities & differences between the Moon & Mercury, including three major discoveries about Mercury made by Mariner 10 & three improved results found by MESSENGER. Consider just intrinsic & rotational properties, not orbital properties
Discuss the differences and similarities between these three business forms : 1. Differences and similarities between...
Discuss the differences and similarities between these three business forms : 1. Differences and similarities between LLC in USA vs SARL in Lebanon 2. Corporation in USA vs S.A.L in Lebanon 3. General Partnership in USA vs. Unlimited Partnership in Lebanon
Explain similarities and differences between assurance and security in a Supply Chain. Explain the distinction between...
Explain similarities and differences between assurance and security in a Supply Chain. Explain the distinction between accounting principles and auditing standards. Explain the distinction between the Generally Accepted Accounting Principles and the International Financial Reporting Standards. Explain the Commerce Clause of the U.S.A. Constitution and the importance to business activities.
What are the similarities and differences between retirement needs and insurance? Explain.
What are the similarities and differences between retirement needs and insurance? Explain.
Explain the similarities and differences between the plant responses thigmomorphogenesis and thigmotropism.
Explain the similarities and differences between the plant responses thigmomorphogenesis and thigmotropism.
In a page, explain the similarities and differences between financial and managerial accounting.
In a page, explain the similarities and differences between financial and managerial accounting.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT