dcsimg

SQLCourse
Interactive Online SQL Training
HOME News MS SQL Oracle DB2 Access MySQL PHP SQL Etc Scripts Links Forums DBA Talk
SQL Courses
1What is SQL?
2Table basics
3Selecting data
4Creating tables
5Inserting into a table
6Updating records
7Deleting records
8Drop a table
9Advanced Queries
10Standalone SQL interpreter
11Advertise on SQLCourse.com
12Database Links
13Technology Jobs
Free Newsletters:
DatabaseDaily

By submitting your information, you agree that sqlcourse.com may send you SQLCourse offers via email, phone and text message, as well as email offers about other products and services that SQLCourse believes may be of interest to you. SQLCourse will process your information in accordance with the Quinstreet Privacy Policy.

 


Deleting Records

The delete statement is used to delete records or rows from the table.

delete from "tablename"

where "columnname"
OPERATOR "value"
[and|or "column"
OPERATOR "value"];

[ ] = optional

[The above example was line wrapped for better viewing on this Web page.]

Examples:

delete from employee;

Note: if you leave off the where clause, all records will be deleted!

delete from employee
where lastname = 'May';

delete from employee
where firstname = 'Mike' or firstname = 'Eric';

To delete an entire record/row from a table, enter "delete from" followed by the table name, followed by the where clause which contains the conditions to delete. If you leave off the where clause, all records will be deleted.

Delete statement exercises

(Use the select statement to verify your deletes):

  1. Jonie Weber-Williams just quit, remove her record from the table.
  2. It's time for budget cuts. Remove all employees who are making over 70000 dollars.

Create at least two of your own delete statements, and then issue a command to delete all records from the table.

Answers to exercises

SQL Interpreter

 

SQL Course Curriculum
<<previous 123456789 next>>