|
Slide 11.13: The UPDATE statement Slide 11.15: The ORDER BY keyword Home |
|
DELETE and DROP Statements
The DELETE statement is used to delete rows in a table.
The syntax of a delete statement is:
|
|
| LastName | FirstName | Address | City |
|---|---|---|---|
| Hansen | Ola | Timoteivn 10 | Sandnes |
| Svendson | Tove | Borgvn 23 | Sandnes |
| Pettersen | Kari | Storgt 20 | Stavanger |
| Rasmussen | Nina | Stien 12 | Stavanger |
SQL> delete from Persons where LastName = 'Rasmussen'; 1 row deleted. SQL> delete from Persons; 3 rows deleted. |
| LastName | FirstName | Address | City |
|---|---|---|---|
| Hansen | Ola | Timoteivn 10 | Sandnes |
| Svendson | Tove | Borgvn 23 | Sandnes |
| Pettersen | Kari | Storgt 20 | Stavanger |
Persons table without deleting the table.
This means that the table structure, attributes, and indexes will be intact.
| LastName | FirstName | Address | City |
|---|
The DROP command is to delete a table (the table structure, attributes, and indexes will also be deleted):
|
|
Customers table may be created by the following command:
SQL> create table Customers ( 2 CustomerID varchar(16), 3 CompanyName varchar(32), 4 ContactName varchar(32), 5 Address varchar(64), 6 City varchar(32), 7 PostalCode varchar(16), 8 Country varchar(32) );Note that the
Customers table is for read only.