1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/ref/truncate.sgml,v 1.23 2007/04/07 17:12:15 tgl Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/ref/truncate.sgml,v 1.24 2007/05/11 19:40:08 neilc Exp $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -31,9 +31,9 @@ TRUNCATE [ TABLE ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ C
31
31
<command>TRUNCATE</command> quickly removes all rows from a set of
32
32
tables. It has the same effect as an unqualified
33
33
<command>DELETE</command> on each table, but since it does not actually
34
- scan the tables it is faster; furthermore it reclaims disk space
35
- immediately, rather than requiring a subsequent vacuum operation.
36
- This is most useful on large tables.
34
+ scan the tables it is faster. Furthermore, it reclaims disk space
35
+ immediately, rather than requiring a subsequent <command>VACUUM</command>
36
+ operation. This is most useful on large tables.
37
37
</para>
38
38
</refsect1>
39
39
@@ -86,35 +86,38 @@ TRUNCATE [ TABLE ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ C
86
86
in the same command. Checking validity in such cases would require table
87
87
scans, and the whole point is not to do one. The <literal>CASCADE</>
88
88
option can be used to automatically include all dependent tables —
89
- but be very careful when using this option, else you might lose data you
89
+ but be very careful when using this option, or else you might lose data you
90
90
did not intend to!
91
91
</para>
92
92
93
93
<para>
94
- <command>TRUNCATE</> will not run any user-defined <literal>ON
95
- DELETE</literal> triggers that might exist for the tables.
94
+ <command>TRUNCATE</> will not run any <literal>ON DELETE</literal>
95
+ triggers that might exist for the tables.
96
96
</para>
97
97
98
- <para>
99
- <command>TRUNCATE</> is not MVCC-safe (see <xref linkend="mvcc">
100
- for general information about MVCC). After truncation, the table
101
- will appear empty to all concurrent transactions, even if they are
102
- using a snapshot taken before the truncation occurred. This will
103
- only be an issue for a transaction that did not touch the table
104
- before the truncation started — any transaction that has done
105
- so would hold at least <literal>ACCESS SHARE</literal> lock,
106
- which would block
107
- <command>TRUNCATE</> until that transaction completes. So
108
- truncation will not cause any apparent inconsistency in the table
109
- contents for successive queries on the same table, but it could
110
- cause visible inconsistency between the contents of the
111
- truncated table and other tables.
112
- </para>
113
-
114
- <para>
115
- <command>TRUNCATE</> is transaction-safe, however: the truncation
116
- will roll back if the surrounding transaction does not commit.
117
- </para>
98
+ <warning>
99
+ <para>
100
+ <command>TRUNCATE</> is not MVCC-safe (see <xref linkend="mvcc">
101
+ for general information about MVCC). After truncation, the table
102
+ will appear empty to all concurrent transactions, even if they
103
+ are using a snapshot taken before the truncation occurred. This
104
+ will only be an issue for a transaction that did not access the
105
+ truncated table before the truncation happened — any
106
+ transaction that has done so would hold at least an
107
+ <literal>ACCESS SHARE</literal> lock, which would block
108
+ <command>TRUNCATE</> until that transaction completes. So
109
+ truncation will not cause any apparent inconsistency in the table
110
+ contents for successive queries on the same table, but it could
111
+ cause visible inconsistency between the contents of the truncated
112
+ table and other tables in the database.
113
+ </para>
114
+
115
+ <para>
116
+ <command>TRUNCATE</> is transaction-safe, however: the truncation
117
+ will be safely rolled back if the surrounding transaction does not
118
+ commit.
119
+ </para>
120
+ </warning>
118
121
</refsect1>
119
122
120
123
<refsect1>
@@ -124,13 +127,13 @@ TRUNCATE [ TABLE ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ C
124
127
Truncate the tables <literal>bigtable</literal> and <literal>fattable</literal>:
125
128
126
129
<programlisting>
127
- TRUNCATE TABLE bigtable, fattable;
130
+ TRUNCATE bigtable, fattable;
128
131
</programlisting>
129
132
</para>
130
133
131
134
<para>
132
135
Truncate the table <literal>othertable</literal>, and cascade to any tables
133
- that are referencing <literal>othertable</literal> via foreign-key
136
+ that reference <literal>othertable</literal> via foreign-key
134
137
constraints:
135
138
136
139
<programlisting>
0 commit comments