File: tutorial-delete.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (50 lines) | stat: -rw-r--r-- 2,102 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>2.9.Deletions</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="tutorial-sql.html" title="Chapter2.The SQL Language">
<link rel="prev" href="tutorial-update.html" title="2.8.Updates">
<link rel="next" href="tutorial-advanced.html" title="Chapter3.Advanced Features">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="tutorial-delete"></a>2.9.Deletions</h2></div></div></div>
<a name="id569532"></a><p>    Rows can be removed from a table using the <code class="command">DELETE</code>
    command.
    Suppose you are no longer interested in the weather of Hayward.
    Then you can do the following to delete those rows from the table:
</p>
<pre class="programlisting">DELETE FROM weather WHERE city = 'Hayward';</pre>
<p>

    All weather records belonging to Hayward are removed.

</p>
<pre class="programlisting">SELECT * FROM weather;</pre>
<p>

</p>
<pre class="screen">     city      | temp_lo | temp_hi | prcp |    date
---------------+---------+---------+------+------------
 San Francisco |      46 |      50 | 0.25 | 1994-11-27
 San Francisco |      41 |      55 |    0 | 1994-11-29
(2 rows)</pre>
<p>
   </p>
<p>    One should be wary of statements of the form
</p>
<pre class="synopsis">DELETE FROM <em class="replaceable"><code>tablename</code></em>;</pre>
<p>

    Without a qualification, <code class="command">DELETE</code> will
    remove  <span class="emphasis"><em>all</em></span>  rows from the given table, leaving it
    empty.  The system will not request confirmation before
    doing this!
   </p>
</div></body>
</html>