我有以下Psql表结构。
表“public.kart_user”:
Column | Type | Modifiers | Storage | Stats target | Description
------------+------------------------+-----------+----------+--------------+-------------
token | character varying(35) | not null | extended | |
cycle | character varying(200) | | extended | |
userid | character varying(200) | | extended | |
proxyid | character varying(200) | | extended | |
salesrepid | character varying(200) | | extended | |
buyer | character varying(200) | | extended | |
salesrep | character varying(200) | | extended | |
discount | integer[] | | extended | |
custid | character varying(200) | | extended | |
category | character varying(200) | | extended | |
users | character varying(500) | | extended | |
validto | date | | plain | |
ratioonly | boolean | | plain | |
proxy | character varying(500) | | extended | |
validfrom | date | | plain | |
notified | boolean | | plain | |
Indexes:
"kartuser_pkey" PRIMARY KEY, btree (token)
Referenced by:
TABLE "kart_space" CONSTRAINT "kart_space_token_fkey" FOREIGN KEY (token) REFERENCES kart_user(token)
TABLE "kart_order" CONSTRAINT "kartorder_token_fkey" FOREIGN KEY (token) REFERENCES kart_user(token)
我想将列标记从varchar更改为uuid而不删除外键
我尝试了以下方法,但失败了。
ALTER TABLE kart_user alter token type uuid using token::uuid;
注意:我不想在任何情况下放弃关系
我该如何解决这个问题?感谢您的回复