PostgreSQL中 drop table指令出现ERROR: cannot drop table userinfo because other objects depend on it
来源:互联网 发布:网络科学引论 编辑:程序博客网 时间:2024/05/17 06:46
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 itDETAIL: constraint userid on table signinlog depends on table userinfoconstraint userid on table sleepreport depends on table userinfoHINT: Use DROP ... CASCADE to drop the dependent objects too.
问题分析:
出现这个问题的原因在于,登录数据的用户和创建这个table的用户不是同一个用户,所以存在这么一个问题。下面我们打印出数据库中的表的信息。
打印数据库中的表(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)
参考资料:
官方网站关于DROP出现问题的分析
内容截图如下:
使用指令:(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)//删除tableblue=# DROP TABLE userinfo CASCADE;NOTICE: drop cascades to 2 other objectsDETAIL: drop cascades to constraint userid on table signinlogdrop cascades to constraint userid on table sleepreportDROP 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)
0 0
- PostgreSQL中 drop table指令出现ERROR: cannot drop table userinfo because other objects depend on it
- Error 3724:Cannot drop the table 'object_name' because it is being used for replication.
- Error 3724:Cannot drop the table 'object_name' because it is being used for replication.
- ERROR: role "data" cannot be dropped because some objects depend on it
- Postgresql之无法删除表(drop table)
- Recover after DROP TABLE, innodb_file_per_table is ON
- Recover after DROP TABLE, innodb_file_per_table is ON
- Cannot drop database "databasename" because it is currently in use.
- SQLite语法 DROP TABLE
- 缓慢的Drop Table
- MySql批量drop table
- MySql批量drop table
- MySql批量drop table
- drop table purge
- drop table tablename purge
- Drop table相关处理
- drop table的优化
- truncate table drop
- Android-WindowManager
- Windows 10下JDK与Studio的安装和环境变量配置
- Spring简介
- 排序中,两个变量的比较
- c++ new 重载
- PostgreSQL中 drop table指令出现ERROR: cannot drop table userinfo because other objects depend on it
- 金字塔
- hdu 5015-矩阵快速幂
- trie树(字典树)
- 职场里根本没人管你怎么办?
- LintCode 407. 加一
- WINDOWS虚拟机 UBUNTU 14.04 下安装ROS经验
- php中利用session保存用户登陆信息
- c++ primer plus学习笔记