删除主键

最近更新时间: 2025-02-18 16:02:00

  • 复制
    复制成功
postgres=# ALTER TABLE t DROP CONSTRAINT t_id_pkey ;
ALTER TABLE
postgres=# \d+ t
                                      Table "tbase.t"
 Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
--------+---------+-----------+----------+---------+----------+--------------+-------------
 id     | integer |           | not null |         | plain    |              | 
 mc     | text    |           |          |         | extended |              | 
Distribute By: SHARD(id)
Location Nodes: ALL DATANODES

如果是分区表,则删除主键要加上cascade,强制删除关联的子表主键。