如果我有table_abc的话。现在,我修改并添加了一些列,如下所示
alter table_Abc add ( congif_id number, sso number);现在,我第二次添加了一些列,以及congif_id和单点登录:
alter table_Abc add ( congif_id number, sso number,name varchar2(100));但这是抛出错误column already exists.
即使名称相同并添加新的名称,alter脚本不应该仍然运行吗?
发布于 2016-03-09 01:36:35
不,这个错误是意料之中的。如有必要,您可以使用动态SQL重新运行DDL脚本,例如:
begin
execute immediate
'alter table table_Abc add ( congif_id number)';
exception
when others then
if sqlcode = -1430 then
null;
end if;
end;
begin
execute immediate
'alter table table_Abc add ( sso number)';
exception
when others then
if sqlcode = -1430 then
null;
end if;
end;
...或者如果你经常做这样的事情:
declare
procedure run_ddl
( p_sql varchar2
, p_ignored_exception integer
)
is
begin
execute immediate p_sql;
exception
when others then
if sqlcode = p_ignored_exception then
null;
end if;
end;
begin
run_ddl ('alter table table_Abc add ( congif_id number)', -1430);
run_ddl ('alter table table_Abc add ( sso number)', -1430);
end;https://stackoverflow.com/questions/35874066
复制相似问题