gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
3.5KB

  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 V1.79.1" /><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><div xmlns="http://www.w3.org/TR/xhtml1/transitional" 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 12.4 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></hr></div><div class="sect1" id="DML-DELETE"><div class="titlepage"><div><div><h2 class="title" style="clear: both">6.3. Deleting Data</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. <code class="command">UPDATE</code> 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">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="dml.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="dml-returning.html">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">Home</a></td><td width="40%" align="right" valign="top"> 6.4. Returning Data From Modified Rows</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1