Difference between revisions of "SQL DELETE"
From Lianjapedia
Yvonne.milne (Talk | contribs) |
|||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Deletes one or more rows from a table | Deletes one or more rows from a table | ||
− | |||
==Syntax== | ==Syntax== | ||
− | DELETE FROM [<database>!]<table> | + | DELETE FROM [<database>! | <database>.]<table> |
[WHERE CURRENT OF <cursor> | <condition>] | [WHERE CURRENT OF <cursor> | <condition>] | ||
==See Also== | ==See Also== | ||
− | [[ADD TABLE]], [[SQL CLOSE|CLOSE]], [[CREATE DATABASE | + | [[ADD TABLE]], [[SQL CLOSE|CLOSE]], [[CREATE DATABASE]], [[DECLARE CURSOR]], [[DROP CURSOR]], [[EXECUTE IMMEDIATE]], [[FETCH]], [[GETENV()]], [[SQL INSERT|INSERT]], [[OPEN]], [[OPEN DATABASE]], [[SET AUTOCATALOG]], [[TRUNCATE TABLE]], [[SQL UPDATE|UPDATE]], [[SQL USE|USE]] |
− | + | ||
==Description== | ==Description== | ||
Line 17: | Line 15: | ||
To perform a DELETE operation you must have the DELETE privilege or be the owner of the table. | To perform a DELETE operation you must have the DELETE privilege or be the owner of the table. | ||
− | + | {| class="wikitable" width="100%" | |
− | {| class="wikitable" | + | !width="30%"|Keywords||Description |
− | !Keywords||Description | + | |
|- | |- | ||
− | |database||The name of the database to which the table belongs | + | |valign="top"|database||The name of the database to which the table belongs. The '!' or '.' character must be included between the database name and the table name. |
|- | |- | ||
− | |table||The name of the table from which to delete the rows. | + | |valign="top"|table||The name of the table from which to delete the rows. |
|- | |- | ||
|WHERE||Specifies which rows are to be deleted. | |WHERE||Specifies which rows are to be deleted. | ||
|- | |- | ||
− | |CURRENT OF cursor||Deletes only the row most recently fetched by the cursor. | + | |valign="top"|CURRENT OF cursor||Deletes only the row most recently fetched by the cursor. |
|- | |- | ||
|condition||Deletes only the rows that satisfy the condition. | |condition||Deletes only the rows that satisfy the condition. | ||
|- | |- | ||
|} | |} | ||
− | |||
==Example== | ==Example== | ||
Line 40: | Line 36: | ||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL|DELETE]] | [[Category:SQL|DELETE]] | ||
[[Category:Commands]] | [[Category:Commands]] |
Latest revision as of 09:50, 23 November 2017
Contents
Purpose
Deletes one or more rows from a table
Syntax
DELETE FROM [<database>! | <database>.]<table>
[WHERE CURRENT OF <cursor> | <condition>]
See Also
ADD TABLE, CLOSE, CREATE DATABASE, DECLARE CURSOR, DROP CURSOR, EXECUTE IMMEDIATE, FETCH, GETENV(), INSERT, OPEN, OPEN DATABASE, SET AUTOCATALOG, TRUNCATE TABLE, UPDATE, USE
Description
The DELETE command executes an immediate physical deletion of the specified records i.e., records are permanently removed from the table, and cannot be recalled.
To perform a DELETE operation you must have the DELETE privilege or be the owner of the table.
Keywords | Description |
---|---|
database | The name of the database to which the table belongs. The '!' or '.' character must be included between the database name and the table name. |
table | The name of the table from which to delete the rows. |
WHERE | Specifies which rows are to be deleted. |
CURRENT OF cursor | Deletes only the row most recently fetched by the cursor. |
condition | Deletes only the rows that satisfy the condition. |
Example
DELETE FROM staff WHERE ord_date < date()