2 $PostgreSQL: pgsql/doc/src/sgml/ref/delete.sgml,v 1.21 2005/01/04 00:39:53 tgl Exp $
3 PostgreSQL documentation
6 <refentry id="SQL-DELETE">
8 <refentrytitle id="SQL-DELETE-TITLE">DELETE</refentrytitle>
9 <refmiscinfo>SQL - Language Statements</refmiscinfo>
13 <refname>DELETE</refname>
14 <refpurpose>delete rows of a table</refpurpose>
17 <indexterm zone="sql-delete">
18 <primary>DELETE</primary>
23 DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
28 <title>Description</title>
31 <command>DELETE</command> deletes rows that satisfy the
32 <literal>WHERE</literal> clause from the specified table. If the
33 <literal>WHERE</literal> clause is absent, the effect is to delete
34 all rows in the table. The result is a valid, but empty table.
39 <xref linkend="sql-truncate" endterm="sql-truncate-title"> is a
40 <productname>PostgreSQL</productname> extension that provides a
41 faster mechanism to remove all rows from a table.
46 By default, <command>DELETE</command> will delete rows in the
47 specified table and all its subtables. If you wish to delete only
48 from the specific table mentioned, you must use the
49 <literal>ONLY</literal> clause.
53 You must have the <literal>DELETE</literal> privilege on the table
54 to delete from it, as well as the <literal>SELECT</literal>
55 privilege for any table whose values are read in the <replaceable
56 class="parameter">condition</replaceable>.
61 <title>Parameters</title>
65 <term><replaceable class="parameter">table</replaceable></term>
68 The name (optionally schema-qualified) of an existing table.
74 <term><replaceable class="parameter">condition</replaceable></term>
77 A value expression that returns a value of type
78 <type>boolean</type> that determines the rows which are to be
87 <title>Outputs</title>
90 On successful completion, a <command>DELETE</> command returns a command
93 DELETE <replaceable class="parameter">count</replaceable>
95 The <replaceable class="parameter">count</replaceable> is the number
96 of rows deleted. If <replaceable class="parameter">count</replaceable> is
97 0, no rows matched the <replaceable
98 class="parameter">condition</replaceable> (this is not considered
104 <title>Examples</title>
107 Delete all films but musicals:
109 DELETE FROM films WHERE kind <> 'Musical';
114 Clear the table <literal>films</literal>:
122 <title>Compatibility</title>
125 This command conforms to the SQL standard.
130 <!-- Keep this comment at the end of the file
135 sgml-minimize-attributes:nil
136 sgml-always-quote-attributes:t
139 sgml-parent-document:nil
140 sgml-default-dtd-file:"../reference.ced"
141 sgml-exposed-tags:nil
142 sgml-local-catalogs:"/usr/lib/sgml/catalog"
143 sgml-local-ecat-files:nil