]> begriffs open source - ai-pg/blob - full-docs/man7/DROP_TABLE.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / DROP_TABLE.7
1 '\" t
2 .\"     Title: DROP TABLE
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "DROP TABLE" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 DROP_TABLE \- remove a table
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 DROP TABLE [ IF EXISTS ] \fIname\fR [, \&.\&.\&.] [ CASCADE | RESTRICT ]
36 .fi
37 .SH "DESCRIPTION"
38 .PP
39 \fBDROP TABLE\fR
40 removes tables from the database\&. Only the table owner, the schema owner, and superuser can drop a table\&. To empty a table of rows without destroying the table, use
41 \fBDELETE\fR
42 or
43 \fBTRUNCATE\fR\&.
44 .PP
45 \fBDROP TABLE\fR
46 always removes any indexes, rules, triggers, and constraints that exist for the target table\&. However, to drop a table that is referenced by a view or a foreign\-key constraint of another table,
47 CASCADE
48 must be specified\&. (CASCADE
49 will remove a dependent view entirely, but in the foreign\-key case it will only remove the foreign\-key constraint, not the other table entirely\&.)
50 .SH "PARAMETERS"
51 .PP
52 IF EXISTS
53 .RS 4
54 Do not throw an error if the table does not exist\&. A notice is issued in this case\&.
55 .RE
56 .PP
57 \fIname\fR
58 .RS 4
59 The name (optionally schema\-qualified) of the table to drop\&.
60 .RE
61 .PP
62 CASCADE
63 .RS 4
64 Automatically drop objects that depend on the table (such as views), and in turn all objects that depend on those objects (see
65 Section\ \&5.15)\&.
66 .RE
67 .PP
68 RESTRICT
69 .RS 4
70 Refuse to drop the table if any objects depend on it\&. This is the default\&.
71 .RE
72 .SH "EXAMPLES"
73 .PP
74 To destroy two tables,
75 films
76 and
77 distributors:
78 .sp
79 .if n \{\
80 .RS 4
81 .\}
82 .nf
83 DROP TABLE films, distributors;
84 .fi
85 .if n \{\
86 .RE
87 .\}
88 .SH "COMPATIBILITY"
89 .PP
90 This command conforms to the SQL standard, except that the standard only allows one table to be dropped per command, and apart from the
91 IF EXISTS
92 option, which is a
93 PostgreSQL
94 extension\&.
95 .SH "SEE ALSO"
96 ALTER TABLE (\fBALTER_TABLE\fR(7)), CREATE TABLE (\fBCREATE_TABLE\fR(7))