Cod*_*key 2 oracle json clob oracle12c
我正在尝试向 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);
Run Code Online (Sandbox Code Playgroud)
以上所有都失败并出现错误:
ERROR execute() failed with: ORA-02253: constraint specification not allowed here
ERROR execute() failed with: ORA-01735: invalid ALTER TABLE option
Run Code Online (Sandbox Code Playgroud)
语法是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 ));
Run Code Online (Sandbox Code Playgroud)