+ 1
What is the difference between Drop, Delete commands
3 Respostas
+ 15
Drop will delete the whole table from database (drop the whole table)
eg: Drop table Student;. // full table is deleted
Delete is used to delete specific entries or specific data in that table..
eg: Delete age from Student where studentName= "Xyz" ;
deletes the age of student named xyz
+ 6
Drop is used for databases and tables, Delete is for records. Drop is non transactional, hence the command is irreversible.
DROP DATABASE destroys a database along with all the tables in it, actually everything in the database.
DROP TABLE deletes all records and table structure.
DELETE removes some or all records from the table (depending on whether or not a WHERE clause is included), the table's structure remains intact, and if transaction is supported, Delete command can be rolled back/committed as necessary.
There's also TRUNCATE command to empty a table, this one is special as it empties the table, and, if the table uses auto-incremented primary key, TRUNCATE resets auto-incremented field to zero. TRUNCATE doesn't support transaction, so rollback can't be used to revert the action.
+ 1
Ipang's answer is very thorough - I'd just like to add that truncate can (sometimes, under certain DBMSs and certain conditions :) ) be rolled back.
https://www.google.ro/amp/s/blog.sqlauthority.com/2010/03/04/sql-server-rollback-truncate-command-in-transaction/amp/