0
点赞
收藏
分享

微信扫一扫

PG数据库操作相关问题以及解决

深夜瞎琢磨 2022-01-26 阅读 40

1.删除分表报错有依赖不能删除

DROP TABLE products;

NOTICE:  constraint orders_product_no_fkey on table orders depends on table products
ERROR:  cannot drop table products because other objects depend on it
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
原因如下,有外部依赖这个表,需要使用以下语句强制删除
The error message contains a useful hint: if you do not want to bother deleting all the dependent objects individually, you can run

DROP TABLE products CASCADE;

引用:
Dependency Tracking

2.更改表名

alter table 表名 rename to 新表名

3.更改字段名

alter table 表名 rename 字段名 to 新字段名

举报

相关推荐

0 条评论