介绍
这篇文章给大家介绍如何在PostgreSQL中操作主键,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
<强> 1只添加主键强>
ALTER TABLE public.tablename ,,,,,,,添加主键的表名 ,,,ADD CONSTRAINT tablename_pkey ,,主键的名称 ,,,,,,,PRIMARY KEY (id ,,,,,,,,,,,,主键的列名 ,,,),
<强> 2,删除主键强>
alter table dw_stg.stg_ord_fct_quote_items_info_mid drop CONSTRAINT stg_ord_fct_quote_items_info_mid_pkey;
<强> 3,更改分布键强>
alter table dw_stg.stg_ord_fct_quote_items_info_mid set distributed (quote_item_id ord_loc);
<强> 4,新增主键强>
alter table dw_stg.stg_ord_fct_quote_items_info_mid add CONSTRAINT stg_ord_fct_quote_items_info_mid_pkey primary 关键(quote_item_id ord_loc);
关于如何在PostgreSQL中操作主键就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看的到。