我正在尝试向 Oracle 表添加一列,并检查我要添加的 CLOB 类型列的 JSON。
ALTER TABLE TAB1 (ADD COL_NEW CLOB CONSTRAINT CONS1 (CLOB IS JSON));
ALTER TABLE TAB1 ADD COL_NEW CLOB CONSTRAINT CONS1 (CLOB IS JSON) ;
ALTER TABLE TAB1 ADD COL_NEW CLOB CONSTRAINT CONS1 (CLOB IS JSON);
以上所有操作都失败并出现错误:
ERROR execute() failed with: ORA-02253: constraint specification not allowed here
ERROR execute() failed with: ORA-01735: invalid ALTER TABLE option
最佳答案
语法为constraint <<constraint name>> <<constraint type>> (<<columns>>
。您正在尝试创建检查约束,因此您的约束类型应为 check
。您还需要在 (<<column name>> is json)
中指定新列的名称。表达式,而不是 clob
数据类型。所以你想要constraint cons1 check( col_new is json )
ALTER TABLE table_name
ADD( column_name CLOB
CONSTRAINT constraint_name CHECK (column_name IS JSON ));
关于json - 向具有 JSON CLOB 约束 Oracle 的表添加列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32703167/