【问题标题】:Can not execute a DDL with Statement DB(postgres) - Java无法使用语句 DB(postgres)执行 DDL - Java
【发布时间】:2014-09-17 16:45:52
【问题描述】:

我需要通过更新数据库(新表、字段和键)来制定 DDL 语句。

但只有当我尝试使用外键添加表并通过添加外键修改表时不起作用,出现错误,但应用程序无限期暂停。

例如:

instanceStatement.execute ("ALTER TABLE pay ADD CONSTRAINT foranea_pay_customer FOREIGN KEY (customerid) REFERENCES customer (customerid) ON UPDATE CASCADE ON DELETE SET NULL;");

请帮忙。

【问题讨论】:

    标签: java postgresql ddl


    【解决方案1】:
    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
      ;
    

    【讨论】:

      猜你喜欢
      • 2011-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-21
      • 2017-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多