oracle修改表中的列

declare v_Count1 int := 0;
v_Count2 int := 0;
v_Count3 int := 0;
v_Count4 int := 0;
v_Count5 int := 0;
v_Count6 int := 0;

begin
select count(1) into v_Count1 from user_all_tables where Upper(Table_Name) = Upper('ZJJHMXBZ');
select count(1) into v_Count4 from user_all_tables where Upper(Table_Name) = Upper('ZJJHMXBZBG');
if(v_Count1 > 0 ) then
select count(1) into v_Count2 from user_tab_cols where Upper(Table_name) = Upper('ZJJHMXBZ') and Upper(Column_Name) = Upper('ZJJHMXBZ_SM');
if(v_Count2 > 0 ) then
execute immediate('alter table ZJJHMXBZ modify ZJJHMXBZ_SM varchar2(4000) ');
end if;
select count(1) into v_Count3 from user_tab_cols where Upper(Table_name) = Upper('ZJJHMXBZ') and Upper(Column_Name) = Upper('ATTRIBUTE15');
if(v_Count3 > 0 ) then
execute immediate('alter table ZJJHMXBZ modify ATTRIBUTE15 varchar2(4000) ');
end if;
end if;
if(v_Count4 > 0 ) then
select count(1) into v_Count5 from user_tab_cols where Upper(Table_name) = Upper('ZJJHMXBZBG') and Upper(Column_Name) = Upper('ZJJHMXBZBG_SM');
if(v_Count5 > 0 ) then
execute immediate('alter table ZJJHMXBZBG modify ZJJHMXBZBG_SM varchar2(4000) ');
end if;
select count(1) into v_Count6 from user_tab_cols where Upper(Table_name) = Upper('ZJJHMXBZBG') and Upper(Column_Name) = Upper('ATTRIBUTE15');
if(v_Count6 > 0 ) then
execute immediate('alter table ZJJHMXBZBG modify ATTRIBUTE15 varchar2(4000) ');
end if;
end if;
end;

posted @ 2021-02-24 16:35  泉城余文乐  Views(133)  Comments(0Edit  收藏  举报