我在PostgreSQL中创建表。然后我不得不使用一列作为外键,所以我改变了我的表,将该列定义为外键。
但我在"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...
请建议任何更正。
答案 0 :(得分:2)
您尝试使用Microsoft sql server语法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是
...ADD table_constraint [ NOT VALID ]