PostgreSQL Drop Table
PostgreSQL uses the DROP TABLE statement to drop a table, including the table data, rules, triggers, and so on, so dropping a table must be done with care; once dropped, all information disappears.
Syntax
DROP TABLE The syntax format is as follows:
DROP TABLE table_name;
Example
In the previous chapter we created two tables, COMPANY and DEPARTMENT. We can first use the \d command to check whether the tables were created successfully:
runoobdb=# \d
List of relations
Schema | Name | Type | Owner
--------+------------+-------+----------
public | company | table | postgres
public | department | table | postgres
(2 rows)
As can be seen from the above result, our tables were created successfully. Next, we drop these two tables:
runoobdb=# drop table department, company;
DROP TABLE
Using the \d command again, the tables can no longer be found:
testdb=# \d
Did not find any relations.