开发者

Postgresql Altering Table

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜