oracle表中增加字段sql

declare v_Count1 int := 0;
v_Count2 int := 0;
begin
select count(1) into v_Count1 from user_all_tables where Upper(Table_Name) = Upper('LSZGZD');
if(v_Count1 > 0 ) then
select count(1) into v_Count2 from user_tab_cols where Upper(Table_name) = Upper('LSZGZD') and Upper(Column_Name) = Upper('LSZGZD_CODE');
if(v_Count2 <= 0 ) then
execute immediate('alter table LSZGZD add LSZGZD_CODE varchar2(36) ');
end if;
end if;
end;
go
declare v_Count1 int := 0;
v_Count2 int := 0;
begin
select count(1) into v_Count1 from user_all_tables where Upper(Table_Name) = Upper('LSZGZD');
if(v_Count1 > 0 ) then
select count(1) into v_Count2 from user_tab_cols where Upper(Table_name) = Upper('LSZGZD') and Upper(Column_Name) = Upper('LSZGZD_TYPE');
if(v_Count2 <= 0 ) then
execute immediate('alter table LSZGZD add LSZGZD_TYPE varchar2(240) ');
end if;
end if;
end;
go

posted @ 2021-08-31 10:16  泉城余文乐  Views(1242)  Comments(0Edit  收藏  举报