SQL DELETE Statement Tutorial

DELETE Statement in SQL

1. Create Table

CREATE TABLE Employee (
    Id INT,
    Name VARCHAR(20),
    City VARCHAR(20)
);

2. Insert Values

INSERT INTO Employee VALUES (1, 'Spiderman', 'Varanasi');

3. View Records

SELECT * FROM Employee;
Employee Table Output

4. Delete Specific Record

To delete an employee where Name = 'Thor':

DELETE FROM Employee WHERE Name = 'Thor';
Delete Thor Record

5. Delete All Records

If you want to remove all rows from the table but keep the table structure intact:

DELETE FROM Employee;

This will clear the data but the table and its columns will remain available for future use.

Delete All Records from Employee Table

Quick Note:

  • DELETE removes rows but not the table structure.
  • Use WHERE clause carefully to avoid deleting unintended rows.
  • TRUNCATE is a faster alternative when you want to delete all records.

Need Help with SQL or Software Development?