delete.sgml
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:4k
源码类别:

数据库系统

开发平台:

Unix_Linux

  1. <refentry id="SQL-DELETE">
  2.  <refmeta>
  3.   <refentrytitle>
  4.    DELETE
  5.   </refentrytitle>
  6.   <refmiscinfo>SQL - Language Statements</refmiscinfo>
  7.  </refmeta>
  8.  <refnamediv>
  9.   <refname>
  10.    DELETE
  11.   </refname>
  12.   <refpurpose>
  13.    Deletes rows from a table
  14.   </refpurpose>
  15.  </refnamediv>
  16.  <refsynopsisdiv>
  17.   <refsynopsisdivinfo>
  18.    <date>1998-04-15</date>
  19.   </refsynopsisdivinfo>
  20.   <synopsis>
  21. DELETE FROM <replaceable class="PARAMETER">table</replaceable> [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
  22.   </synopsis>
  23.   <refsect2 id="R2-SQL-DELETE-1">
  24.    <refsect2info>
  25.     <date>1998-04-15</date>
  26.    </refsect2info>
  27.    <title>
  28.     Inputs
  29.    </title>
  30.    <para>
  31.     <variablelist>
  32.      <varlistentry>
  33.       <term><replaceable class="parameter">table</replaceable></term>
  34.       <listitem>
  35.        <para>
  36. The name of an existing table.
  37.        </para>
  38.       </listitem>
  39.      </varlistentry>
  40.      <varlistentry>
  41.       <term><replaceable class="parameter">condition</replaceable></term>
  42.       <listitem>
  43.        <para>
  44. This is an SQL selection query which returns the rows which
  45. are to be deleted.
  46.        </para>
  47.        <para>
  48. Refer to the SELECT statement for further description
  49. of the WHERE clause.
  50.        </para>
  51.       </listitem>
  52.      </varlistentry>
  53.     </variablelist>
  54.    </para>
  55.   </refsect2>
  56.   <refsect2 id="R2-SQL-DELETE-2">
  57.    <refsect2info>
  58.     <date>1998-04-15</date>
  59.    </refsect2info>
  60.    <title>
  61.     Outputs
  62.    </title>
  63.    <para>
  64.     <variablelist>
  65.      <varlistentry>
  66.       <term><computeroutput>
  67. DELETE <replaceable class="parameter">count</replaceable>
  68.        </computeroutput></term>
  69.       <listitem>
  70.        <para>
  71. Message returned if items are successfully deleted. The
  72. <replaceable class="parameter">count</replaceable> is the number
  73. of rows deleted.
  74.        </para>
  75.        <para>
  76. If <replaceable class="parameter">count</replaceable> is 0,
  77. no rows were deleted.
  78.        </para>
  79.       </listitem>
  80.      </varlistentry>
  81.     </variablelist>
  82.    </para>
  83.   </refsect2>
  84.  </refsynopsisdiv>
  85.  <refsect1 id="R1-SQL-DELETE-1">
  86.   <refsect1info>
  87.    <date>1998-04-15</date>
  88.   </refsect1info>
  89.   <title>
  90.    Description
  91.   </title>
  92.   <para>
  93.    <command>DELETE</command> removes rows which satisfy the WHERE
  94.    clause from the specified table.
  95.   </para>
  96.   <para>
  97.    If the <firstterm>condition</firstterm> (WHERE clause) is absent,
  98.    the effect is to delete all rows in the table.
  99.    The result is a valid, but empty table.
  100.   </para>
  101.   <para>
  102.    You must have write access to the table in order to modify
  103.    it, as well as read access to any table whose values are
  104.    read in the <replaceable class="parameter">condition</replaceable>.
  105.   </para>
  106.  </refsect1>
  107.  <refsect1 id="R1-SQL-DELETE-2">
  108.   <title>
  109.    Usage
  110.   </title>
  111.   <para>
  112.    Remove all films but musicals:
  113.    <programlisting>
  114. DELETE FROM films WHERE kind &lt;&gt; 'Musical';
  115. SELECT * FROM films;
  116. code |title                    |did| date_prod|kind      |len
  117. -----+-------------------------+---+----------+----------+------
  118. UA501|West Side Story          |105|1961-01-03|Musical   | 02:32
  119. TC901|The King and I           |109|1956-08-11|Musical   | 02:13
  120. WD101|Bed Knobs and Broomsticks|111|          |Musical   | 01:57
  121. (3 rows)
  122.    </programlisting>
  123.   </para>
  124.   <para>
  125.    Clear the table <literal>films</literal>:
  126.    <programlisting>
  127. DELETE FROM films;
  128. SELECT * FROM films;
  129. code|title|did|date_prod|kind|len
  130. ----+-----+---+---------+----+---
  131. (0 rows)
  132.    </programlisting>      
  133.   </para>
  134.  </refsect1>
  135.  <refsect1 id="R1-SQL-DELETE-3">
  136.   <title>
  137.    Compatibility
  138.   </title>
  139.   <para>
  140.   </para>
  141.   <refsect2 id="R2-SQL-DELETE-4">
  142.    <refsect2info>
  143.     <date>1998-04-15</date>
  144.    </refsect2info>
  145.    <title>
  146.     SQL92
  147.    </title>
  148.    <para>
  149.     <acronym>SQL92</acronym> allows a positioned DELETE statement:
  150.    
  151.     <synopsis>
  152. DELETE FROM <replaceable class="parameter">table</replaceable> WHERE
  153.     CURRENT OF <replaceable class="parameter">cursor</replaceable>
  154.     </synopsis>
  155.     where <replaceable class="parameter">cursor</replaceable>
  156.     identifies an open cursor.
  157.     Interactive cursors in <productname>Postgres</productname> are read-only.
  158.    </para>
  159.   </refsect2>
  160.  </refsect1>
  161. </refentry>
  162. <!-- Keep this comment at the end of the file
  163. Local variables:
  164. mode: sgml
  165. sgml-omittag:nil
  166. sgml-shorttag:t
  167. sgml-minimize-attributes:nil
  168. sgml-always-quote-attributes:t
  169. sgml-indent-step:1
  170. sgml-indent-data:t
  171. sgml-parent-document:nil
  172. sgml-default-dtd-file:"../reference.ced"
  173. sgml-exposed-tags:nil
  174. sgml-local-catalogs:"/usr/lib/sgml/catalog"
  175. sgml-local-ecat-files:nil
  176. End:
  177. -->