The SQL DELETE Statement:

The SQL DELETE Query or statement is used to delete rows in a table.

Syntax:

DELETE FROM table_name WHERE column_name = some_value

Example:

Using ‘Userinfo’ Table

Query: DELETE FROM UserInfo WHERE LastName = ‘Rasmussen’

LastName FirstName Address City Year
Hansen Ola Timoteivn 10 Sandnes 1951
Svendson Tove Borgvn 23 Sandnes 1978
Rasmussen Nina Stien 12 Stavanger

The Result:

LastName FirstName Address City Year
Hansen Ola Timoteivn 10 Sandnes 1951
Svendson Tove Borgvn 23 Sandnes 1978

DELETE All Rows:

It is possible to delete all rows in a table without deleting the structure of table. This means that the table structure, attributes, and indexes will be as it is.

Syntax:

DELETE FROM table_name

                  OR

DELETE * FROM table_name

Leave a Reply

Your email address will not be published. Required fields are marked *