更改 clob 列的约束
Change constraint of clob column
我想将 clob 列的 NOT NULL
约束更改为 NULL
约束。然而,当尝试
ALTER TABLE myTable ALTER COLUMN myClobCol clob NULL;
或
ALTER TABLE myTable modify myClobCol clob NULL;
我收到以下错误:
ORA-01735: invalid ALTER TABLE option
或
ORA-22859: invalid modification of columns
我做错了什么?在这种情况下我是否也必须使用临时列?我知道使用临时列将数据类型从 clob 更改为 varchar2 的场景,但在这里我只想更改约束。为什么这不可能?
提前致谢!
您正在尝试将列的类型设置为 CLOB
至 CLOB
,这是无效的,因为任何设置对象列的尝试都是无效的。仅使用 ALTER TABLE myTable modify myClobCol NULL;
设置列的 NULL 约束。
试试这个:
declare
col_nullable varchar2(1);
begin
select nullable into col_nullable
from user_tab_columns
where table_name = 'myTable'
and column_name = 'myClobCol';
if col_nullable = 'N' then
execute immediate 'alter table mytable modify (myClobCol null)';
end if;
end;
我想将 clob 列的 NOT NULL
约束更改为 NULL
约束。然而,当尝试
ALTER TABLE myTable ALTER COLUMN myClobCol clob NULL;
或
ALTER TABLE myTable modify myClobCol clob NULL;
我收到以下错误:
ORA-01735: invalid ALTER TABLE option
或
ORA-22859: invalid modification of columns
我做错了什么?在这种情况下我是否也必须使用临时列?我知道使用临时列将数据类型从 clob 更改为 varchar2 的场景,但在这里我只想更改约束。为什么这不可能?
提前致谢!
您正在尝试将列的类型设置为 CLOB
至 CLOB
,这是无效的,因为任何设置对象列的尝试都是无效的。仅使用 ALTER TABLE myTable modify myClobCol NULL;
设置列的 NULL 约束。
试试这个:
declare
col_nullable varchar2(1);
begin
select nullable into col_nullable
from user_tab_columns
where table_name = 'myTable'
and column_name = 'myClobCol';
if col_nullable = 'N' then
execute immediate 'alter table mytable modify (myClobCol null)';
end if;
end;