]> begriffs open source - ai-pg/blob - full-docs/html/dml-delete.html
Include latest toc output
[ai-pg] / full-docs / html / dml-delete.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>6.3. Deleting Data</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="dml-update.html" title="6.2. Updating Data" /><link rel="next" href="dml-returning.html" title="6.4. Returning Data from Modified Rows" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">6.3. Deleting Data</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="dml-update.html" title="6.2. Updating Data">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="dml.html" title="Chapter 6. Data Manipulation">Up</a></td><th width="60%" align="center">Chapter 6. Data Manipulation</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="dml-returning.html" title="6.4. Returning Data from Modified Rows">Next</a></td></tr></table><hr /></div><div class="sect1" id="DML-DELETE"><div class="titlepage"><div><div><h2 class="title" style="clear: both">6.3. Deleting Data <a href="#DML-DELETE" class="id_link">#</a></h2></div></div></div><a id="id-1.5.5.5.2" class="indexterm"></a><a id="id-1.5.5.5.3" class="indexterm"></a><p>
3    So far we have explained how to add data to tables and how to
4    change data.  What remains is to discuss how to remove data that is
5    no longer needed.  Just as adding data is only possible in whole
6    rows, you can only remove entire rows from a table.  In the
7    previous section we explained that SQL does not provide a way to
8    directly address individual rows.  Therefore, removing rows can
9    only be done by specifying conditions that the rows to be removed
10    have to match.  If you have a primary key in the table then you can
11    specify the exact row.  But you can also remove groups of rows
12    matching a condition, or you can remove all rows in the table at
13    once.
14   </p><p>
15    You use the <a class="xref" href="sql-delete.html" title="DELETE"><span class="refentrytitle">DELETE</span></a>
16    command to remove rows; the syntax is very similar to the
17    <a class="xref" href="sql-update.html" title="UPDATE"><span class="refentrytitle">UPDATE</span></a> command.  For instance, to remove all
18    rows from the products table that have a price of 10, use:
19 </p><pre class="programlisting">
20 DELETE FROM products WHERE price = 10;
21 </pre><p>
22   </p><p>
23    If you simply write:
24 </p><pre class="programlisting">
25 DELETE FROM products;
26 </pre><p>
27    then all rows in the table will be deleted!  Caveat programmer.
28   </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="dml-update.html" title="6.2. Updating Data">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="dml.html" title="Chapter 6. Data Manipulation">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="dml-returning.html" title="6.4. Returning Data from Modified Rows">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6.2. Updating Data </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 6.4. Returning Data from Modified Rows</td></tr></table></div></body></html>