SQL DELETE Statement


The SQL DELETE statement is used to delete or remove the existing records in a specific table.

The SQL DELETE statement is also used to delete all records (without SQL WHERE clause) or specific records that match a specified criteria using SQL WHERE clause. This is accomplished by carefully constructing a where clause.


SQL DELETE Syntax

The basic syntax of SQL DELETE statement with SQL WHERE clause is as follows:


DELETE FROM table_name1
WHERE some_column_name = some_value_1;

You can combine N number of conditions using AND or OR operators.

You do not need to list column names in the SQL DELETE statement since you are removing the entire record from the table.

Note: The SQL WHERE clause in the SQL DELETE statement!

The SQL WHERE clause specifies criteria to delete, which row or rows that should be deleted. If you omit the SQL WHERE clause, all rows will be removed!


Search Keys

  • sql delete query
  • delete sql statement
  • delete row in sql
  • sql delete all rows
  • sql delete row
  • sql delete record
  • sql delete statement
  • delete record sql
  • delete query in sql
  • delete from table
  • oracle delete query
  • delete data from sql table
  • delete record in sql
  • how to delete a table in sql
  • delete syntax in sql
  • delete from select
  • sql delete example
  • t sql delete join
  • mssql delete from
  • sql server delete from join
  • delete sql command
  • delete data from table
  • sql delete data
  • sql query to delete a row
  • delete sql example

Sample Database Table - Books

BookId BookName BookPrice RelYear DomainName AuthorName
1 The Complete Guide to SQL Server 155 2009 Performance Dharan
2 Making Sense Of SQL 199.97 2006 Programming Padmavathi
3 Understanding the New SQL 110 2007 Programming Varshini Kutty
4 Sql Server Concurrency 205 2007 Programming Nirmala
5 Postgre Sql Server Programming 71.87 2008 Security Chandra
6 Oracle Database 11G New Features 115 2007 Database Keshavan
7 Head First SQL 145 2010 Optimization Pandurengan
8 The Complete Guide to MySql 85 2007 Administration Dharan

Sample Database Table Structure - Books

Column Name Data Type
BookID Number
BookName Text
BookPrice Number
RelYear Number
DomainName Text
AuthorName Text

Text Column Vs Numeric Column

SQL requires single or double(most database support) quotes around text or string values. However, we write numeric fields without quotes:


SQL DELETE Example

Example 1

The following SQL statement will delete a existing row from column "BookID = 7", in the "Books" table:


DELETE FROM Books
WHERE 
BookID = 7;

The result of above query is:

BookId BookName BookPrice RelYear DomainName AuthorName
1 The Complete Guide to SQL Server 155 2009 Performance Dharan
2 Making Sense Of SQL 199.97 2006 Programming Padmavathi
3 Understanding the New SQL 110 2007 Programming Varshini Kutty
4 Sql Server Concurrency 205 2007 Programming Nirmala
5 Postgre Sql Server Programming 71.87 2008 Security Chandra
6 Oracle Database 11G New Features 115 2007 Database Keshavan
8 The Complete Guide to MySql 85 2007 Administration Dharan

Example 2

The following SQL statement will delete multiple existing row(s) from column BookPrice less than "200" and DomainName = "Programming", in the "Books" table:


DELETE FROM Books
WHERE 
BookPrice < 200 AND DomainName = 'Programming';

The result of above query is:

BookId BookName BookPrice RelYear DomainName AuthorName
1 The Complete Guide to SQL Server 155 2009 Performance Dharan
4 Sql Server Concurrency 205 2007 Programming Nirmala
5 Postgre Sql Server Programming 71.87 2008 Security Chandra
6 Oracle Database 11G New Features 115 2007 Database Keshavan
8 The Complete Guide to MySql 85 2007 Administration Dharan

Example 3

The following SQL statement will delete all existing rows from the "Books" table:


DELETE FROM Books;

The result of above query is:

BookId BookName BookPrice RelYear DomainName AuthorName

Search Keys

  • delete sql data
  • sql command to delete a row
  • query to delete a row
  • sql query to delete a row from table
  • delete rows in a table
  • sql delete row query
  • sql delete row command
  • sql delete query example
  • sql delete table data
  • sql query delete row
  • sql delete order by
  • ms sql delete statement
  • postgres delete
  • sql delete multiple tables
  • delete records from sql table
  • delete where
  • delete values sql
  • delete sql record
  • sql clear command
  • sql clear table contents
  • sql clear table
  • drop record sql
  • remove record sql
  • sql remove data from table
  • sql delete from multiple tables in one statement