在PostgreSQL中更改表时遇到错误 [英] Facing error while Altering table in PostgreSQL
问题描述
我在PostgreSQL中创建表。然后,我不得不使用列作为外键,因此我更改了表以将该列定义为外键。
但是我在 WITH
时出错,
I was creating tables in PostgreSQL. Then I had to use an column as foreign key so I altered my table to define that column as foreign key.
But I got an error at "WITH"
,
ALTER TABLE Account WITH NOCHECK ADD CONSTRAINT FK_Account_AccountCPCMapping FOREIGN KEY(nAccountCPCMappingID)
REFERENCES AccountCPCMapping (nAccountCPCMappingID);
我遇到了类似的错误,
ERROR: syntax error at or near "WITH"
LINE 1: ALTER TABLE Account WITH NOCHECK ADD CONSTRAINT FK_Account...
请提出任何更正建议。
推荐答案
您尝试使用Microsoft sql服务器语法 https:// docs.microsoft.com/zh-cn/sql/t-sql/statements/alter-table-transact-sql
you try to use Microsoft sql server syntax https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql
而Postgres语法 https://www.postgresql.org/docs/current/static/sql-altertable .html 是
while Postgres syntax https://www.postgresql.org/docs/current/static/sql-altertable.html is
... ADD table_constraint [NOT VALID]
这篇关于在PostgreSQL中更改表时遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!