数据库创建主键约束名称不能跟表名一样,否则报错

数据库导出 需要用\copy,并且需要在本地用psql连接上去,不需要用use命令,不能再本地pg界面运行,注意多行时,分次间隔复制;
数据库创建主键约束名称不能跟表名一样,否则会报relation已经存在,删除表由显示table不存在,如下:


CREATE TABLE public.t_add_shixin_predict_features
(
    id VARCHAR(100) NOT NULL,
    company_name TEXT NOT NULL,
    shixin_label INTEGER DEFAULT 0,
    network_share_or_pos_shixin_cnt INTEGER DEFAULT 0,
CONSTRAINT t_add_shixin_predict_features PRIMARY KEY (id)
)
WITH (
    OIDS=FALSE
);

CONSTRAINT t_new_add_shixin_predict_features PRIMARY KEY (id) 里面的跟创建的数据库表名不一样。
#此处t_new_add_shixin_predict_features 与t_add_shixin_predict_features不一样;

猜你喜欢

转载自blog.csdn.net/sinat_26566137/article/details/80407210