PostgreSQL delete table
PostgreSQL uses the DROP TABLE statement to delete tables, including tabular data, rules, triggers, etc., so delete the table carefully, and all information disappears after deletion.
DROP TABLE The syntax is as follows:
DROP TABLE table_name;
In the previous chapter, we created two tables, COMPANY and DEPARTMENT. We can use the \d command to see if the form was created successfully:
welookupsdb=# \d List of relations Schema | Name | Type | Owner --------+------------+-------+-------- -- public | Company | table | postgres public | Department | table | postgres (2rows)
As you can see from the above results, our form has been created successfully, then we delete the two tables:
welookupsdb=# drop table Department, company; DROP TABLE
If you use the \d command to view it, you will not be able to find the table:
testdb=# \d Did not find any relations.