declare n number;
begin
select count(1) into n from all_table_columns where table_name = upper('表名') and column_name = upper('字段名');
if n = 0 then
begin
select count(1) into n from all_table_columns where table_name = upper('表名') and column_name = upper('字段名');
if n = 0 then
dbms.put_line('字段不存在');
execute immediate 'alter table 表名 add 字段名 字段类型(长度)';
if n > 0 then
dbms_output.put_line('字段已存在');
end if;
end;
if n > 0 then
dbms_output.put_line('字段已存在');
end if;
end;
/