Previous Page | Next Page

The SQL Procedure

DELETE Statement


Removes one or more rows from a table or view that is specified in the FROM clause.
Restriction: You cannot use DELETE FROM on a table that is accessed by an engine that does not support UPDATE processing.
Featured in: Combining Two Tables

DELETE
FROM table-name|sas/access-view|proc-sql-view <AS alias>
<WHERE sql-expression>;

Arguments

alias

assigns an alias to table-name, sas/access-view, or proc-sql-view.

sas/access-view

specifies a SAS/ACCESS view that you are deleting rows from.

proc-sql-view

specifies a PROC SQL view that you are deleting rows from. proc-sql-view can be a one-level name, a two-level libref.view name, or a physical pathname that is enclosed in single quotation marks.

sql-expression

See sql-expression.

table-name

specifies the table that you are deleting rows from. table-name can be a one-level name, a two-level libref.table name, or a physical pathname that is enclosed in single quotation marks.

CAUTION:
Recursive table references can cause data integrity problems.

While it is possible to recursively reference the target table of a DELETE statement, doing so can cause data integrity problems and incorrect results. Constructions such as the following should be avoided:

proc sql;
   delete from a
      where var1 > (select min(var2) from a);

  [cautionend]


Deleting Rows through Views

You can delete one or more rows from a view's underlying table, with some restrictions. See Updating PROC SQL and SAS/ACCESS Views in the SAS 9.2 SQL Procedure User's Guide.

CAUTION:
If you omit a WHERE clause, then the DELETE statement deletes all the rows from the specified table or the table that is described by a view.   [cautionend]

Previous Page | Next Page | Top of Page