~ubuntu-branches/ubuntu/utopic/pgadmin3/utopic-proposed

« back to all changes in this revision

Viewing changes to docs/en_US/pg/sql-delete.html

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Enrici
  • Date: 2004-12-14 23:46:39 UTC
  • Revision ID: james.westby@ubuntu.com-20041214234639-tve0i5l49fq13jli
Tags: upstream-1.2.0
ImportĀ upstreamĀ versionĀ 1.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 
4
<title>DELETE</title>
 
5
<link rel="stylesheet" href="stylesheet.css" type="text/css">
 
6
<link rev="made" href="pgsql-docs@postgresql.org">
 
7
<meta name="generator" content="DocBook XSL Stylesheets V1.64.1">
 
8
<link rel="home" href="index.html" title="PostgreSQL 8.0.0beta5 Documentation">
 
9
<link rel="up" href="sql-commands.html" title="SQL Commands">
 
10
<link rel="previous" href="sql-declare.html" title="DECLARE">
 
11
<link rel="next" href="sql-dropaggregate.html" title="DROP AGGREGATE">
 
12
</head>
 
13
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
 
14
<a name="sql-delete"></a><div class="titlepage">
 
15
<div></div>
 
16
<div></div>
 
17
</div>
 
18
<div class="refnamediv">
 
19
<h2>Name</h2>
 
20
<p>DELETE &#8212; delete rows of a table</p>
 
21
</div>
 
22
<a name="id2682894"></a><div class="refsynopsisdiv">
 
23
<h2>Synopsis</h2>
 
24
<pre class="synopsis">DELETE FROM [ ONLY ] <i class="replaceable"><tt>table</tt></i> [ WHERE <i class="replaceable"><tt>condition</tt></i> ]</pre>
 
25
</div>
 
26
<div class="refsect1" lang="en">
 
27
<a name="id2682922"></a><h2>Description</h2>
 
28
<p>   <tt class="command">DELETE</tt> deletes rows that satisfy the
 
29
   <tt class="literal">WHERE</tt> clause from the specified table.  If the
 
30
   <tt class="literal">WHERE</tt> clause is absent, the effect is to delete
 
31
   all rows in the table.  The result is a valid, but empty table.
 
32
  </p>
 
33
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;">
 
34
<h3 class="title">Tip</h3>
 
35
<p>     <a href="sql-truncate.html">TRUNCATE</a> is a
 
36
     <span class="productname">PostgreSQL</span> extension which provides a
 
37
     faster mechanism to remove all rows from a table.
 
38
    </p>
 
39
</div>
 
40
<p>   By default, <tt class="command">DELETE</tt> will delete rows in the
 
41
   specified table and all its subtables. If you wish to only delete
 
42
   from the specific table mentioned, you must use the
 
43
   <tt class="literal">ONLY</tt> clause.
 
44
  </p>
 
45
<p>   You must have the <tt class="literal">DELETE</tt> privilege on the table
 
46
   to delete from it, as well as the <tt class="literal">SELECT</tt>
 
47
   privilege for any table whose values are read in the <i class="replaceable"><tt>condition</tt></i>.
 
48
  </p>
 
49
</div>
 
50
<div class="refsect1" lang="en">
 
51
<a name="id2683009"></a><h2>Parameters</h2>
 
52
<div class="variablelist"><dl>
 
53
<dt><span class="term"><i class="replaceable"><tt>table</tt></i></span></dt>
 
54
<dd><p>      The name (optionally schema-qualified) of an existing table.
 
55
     </p></dd>
 
56
<dt><span class="term"><i class="replaceable"><tt>condition</tt></i></span></dt>
 
57
<dd><p>      A value expression that returns a value of type
 
58
      <tt class="type">boolean</tt> that determines the rows which are to be
 
59
      deleted.
 
60
     </p></dd>
 
61
</dl></div>
 
62
</div>
 
63
<div class="refsect1" lang="en">
 
64
<a name="id2683041"></a><h2>Outputs</h2>
 
65
<p>   On successful completion, a <tt class="command">DELETE</tt> command returns a command
 
66
   tag of the form
 
67
</p>
 
68
<pre class="screen">DELETE <i class="replaceable"><tt>count</tt></i></pre>
 
69
<p>
 
70
   The <i class="replaceable"><tt>count</tt></i> is the number
 
71
   of rows deleted.  If <i class="replaceable"><tt>count</tt></i> is
 
72
   0, no rows matched the <i class="replaceable"><tt>condition</tt></i> (this is not considered
 
73
   an error).
 
74
  </p>
 
75
</div>
 
76
<div class="refsect1" lang="en">
 
77
<a name="id2683084"></a><h2>Examples</h2>
 
78
<p>   Delete all films but musicals:
 
79
</p>
 
80
<pre class="programlisting">DELETE FROM films WHERE kind &lt;&gt; 'Musical';</pre>
 
81
<p>
 
82
  </p>
 
83
<p>   Clear the table <tt class="literal">films</tt>:
 
84
</p>
 
85
<pre class="programlisting">DELETE FROM films;</pre>
 
86
<p>      
 
87
  </p>
 
88
</div>
 
89
<div class="refsect1" lang="en">
 
90
<a name="id2683112"></a><h2>Compatibility</h2>
 
91
<p>   This command conforms to the SQL standard.
 
92
  </p>
 
93
</div>
 
94
</div></body>
 
95
</html>