SQL DELETE Statement

previous next


The DELETE Statement

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

Syntax

DELETE FROM tableName WHERE columnName = someValue;

 


Delete a Row

 From this "Books" table:

Title

Author

Publisher

Year

الدورة الدموية

إبن النفيس

دار العلم

1650

Java 2

L. Johnston

Fast Press

2002

Linux and Unix

J. Sam

Fast Press

2004

Linux Distributions

J. Sam

Fast Press

2003

Operating Systems

M. Stone

Coriolis

2005

Web Programming

K. Yariv

East Edition

2006

XML Language

M. Salim

Knowledge Press

2000

 

The book having the title "Linux Distributions" is going to be deleted:

DELETE FROM Books WHERE Title = 'Linux Distributions';

The result is:

Title

Author

Publisher

Year

الدورة الدموية

إبن النفيس

دار العلم

1650

Java 2

L. Johnston

Fast Press

2002

Linux and Unix

J. Sam

Fast Press

2004

Operating Systems

M. Stone

Coriolis

2005

Web Programming

K. Yariv

East Edition

2006

XML Language

M. Salim

Knowledge Press

2000

 


Delete All Rows

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

DELETE FROM tableName;

 


Test your SQL Skills

To test your SQL skills click here.


previous next