开发者

Postgresql Altering Table

开发者 https://www.devze.com 2023-01-01 04:35 出处:网络
Is it possible to alter a table to a开发者_如何学Cdd a new column and make that column a foreign key to another table in a single command in Postgresql? \"alter table x add column y id references z(id

Is it possible to alter a table to a开发者_如何学Cdd a new column and make that column a foreign key to another table in a single command in Postgresql? "alter table x add column y id references z(id)" doesn't seem to work as I had hoped.


You can do it. What is "y id"? May be

alter table x add column y int references z(id)


BEGIN
ALTER TABLE ... ADD COLUMN ...
ALTER TABLE ... ADD CONSTRAINT ...
COMMIT

You can't convince me it's not a single command :).

0

精彩评论

暂无评论...
验证码 换一张
取 消