laika222
4/17/2017 - 4:38 PM

DELETE, TRUNCATE, DROP TABLE

How to delete from a table.

-- DELETE FROM, deletes certain rows from a table
DELETE FROM orders1 WHERE OrderID = 36;

-- DELETE FROM, deletes all rows from a table without deleting the table
DELETE * FROM orders1;

-- DROP TABLE, deletes the entire table the entire table, including the structure of the table
DROP TABLE orders;

-- TRUNCATE TABLE clears the entire table in a more efficient, quick manner than DELETE. Storage physically deallocated, rows not individually removed. Will fail if the table is referenced by a foreign key constraint in another table.
TRUNCATE TABLE orders1;