小编Vic*_*Liu的帖子

POSTGRES:将主键类型从varchar更改为uuid,并由其他tabless引用

我有表客户和用户,我想将他们的ID从字符变为uuid.

=>\d customers;
         Table "public.customers"
  Column  |       Type        | Modifiers
----------+-------------------+-----------
 id       | character varying | not null
 name     | character varying | not null
Indexes:
    "customers_pkey" PRIMARY KEY, btree (id)
    "customers_name_key" UNIQUE CONSTRAINT, btree (name)
Referenced by:
    TABLE "users" CONSTRAINT "users_customer_id_fkey" FOREIGN KEY (customer_id) REFERENCES customers(id) DEFERRABLE INITIALLY DEFERRED

=>\d users;
             Table "public.users"
    Column     |       Type        | Modifiers
---------------+-------------------+-----------
 id            | character varying | not null
 name          | character varying | not null
 customer_id   | character varying | not …
Run Code Online (Sandbox Code Playgroud)

postgresql

6
推荐指数
1
解决办法
1769
查看次数

标签 统计

postgresql ×1