我需要通过更新数据库(新表,字段和键)来创建DDL语句。
但是只有当我尝试使用外键添加表并通过添加外键修改表时才会起作用,得到错误,但应用程序会无限期暂停。
例如:
instanceStatement.execute ("ALTER TABLE pay ADD CONSTRAINT foranea_pay_customer FOREIGN KEY (customerid) REFERENCES customer (customerid) ON UPDATE CASCADE ON DELETE SET NULL;");
请帮助。
答案 0 :(得分:0)
ALTER TABLE
ADD CONSTRAINT pay foranea_pay_customer -- <<-- one token too many here
FOREIGN KEY (customerid)
REFERENCES customer (customerid)
ON UPDATE CASCADE ON DELETE SET NULL
;
试试这个:
ALTER TABLE pay -- <<-- maybe here ???
ADD CONSTRAINT foranea_pay_customer
FOREIGN KEY (customerid)
REFERENCES customer (customerid)
ON UPDATE CASCADE ON DELETE SET NULL
;