PostgreSQL中 drop table指令出现ERROR: cannot drop table user
发布时间:2020-12-13 17:08:28 所属栏目:百科 来源:网络整理
导读:PostgreSQL中 drop table指令出现ERROR: cannot drop table userinfo because other objects depend on it。 blue=# drop table userinfo; //删除table指令//错误信息提示ERROR: cannot drop table userinfo because other objects depend on it DETAIL: con
PostgreSQL中 drop table指令出现ERROR: cannot drop table userinfo because other objects depend on it。 blue=# drop table userinfo; //删除table指令
//错误信息提示
ERROR: cannot drop table userinfo because other objects depend on it DETAIL: constraint userid on table signinlog depends on table userinfo constraint userid on table sleepreport depends on table userinfo HINT: Use DROP ... CASCADE to drop the dependent objects too.
问题分析: 打印数据库中的表(PS:指令:“d”) blue=# d //查看数据库中的表
List of relations
Schema | Name | Type | Owner --------+-------------+-------+-------------
public | deviceinfo | table | sxw
public | signinlog | table | sxw
public | sleepreport | table | sxw
public | userinfo | table | postgres
(4 rows)
参考资料: 内容截图如下: 使用指令:(PS: blue=#指当前是名字为blue的数据库) blue=# DROP TABLE userinfo CASCADE;//删除table指令
下面将我删除table的操作以及d查询的结果粘贴如下: //删除table之前 d 查看数据库中的表
blue=# d
List of relations
Schema | Name | Type | Owner
--------+-------------+-------+-------------
public | deviceinfo | table | sxw
public | signinlog | table | sxw
public | sleepreport | table | sxw
public | userinfo | table | postgres
(4 rows)
//删除table
blue=# DROP TABLE userinfo CASCADE;
NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to constraint userid on table signinlog drop cascades to constraint userid on table sleepreport DROP TABLE //删除后,d 查看数据库中的表 blue=# d List of relations Schema | Name | Type | Owner --------+-------------+-------+------------- public | deviceinfo | table | sxw public | signinlog | table | sxw public | sleepreport | table | sxw (3 rows)
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |