PostgreSQL 使用 DROP TABLE 语句来删除表格,包含表格数据、规则、触发器等,所以删除表格要慎重,删除后所有信息就消失了。
语法
DROP TABLE 语法格式如下:
DROP TABLE table_name;
实例
我们可以使用 \d 命令来查看表格:
hgdb=# \d
List of relations
Schema | Name | Type | Owner
--------+------------+-------+----------
public | testable | table | postgres
(1 rows)
从以上结果可以看出,我们表格已经创建成功,接下来我们删除这两个表格:
hgdb=# drop table testable;
DROP TABLE