前端之家收集整理的这篇文章主要介绍了
ORACLE 为表添加字段,没有添加,有就跳过,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
DECLARE
v_sql VARCHAR2(200);
v_table VARCHAR2(30);
v_clums NUMBER;
CURSOR C1 IS SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME LIKE 'UE_GW_%';
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO v_table;
select count(column_name) INTO v_clums from user_tab_columns where table_name= v_table AND COLUMN_NAME = 'HZZSY';
IF v_clums = 0 THEN
v_sql:='ALTER TABLE '||v_table||' ADD HZZSY VARCHAR2(50)';
EXECUTE IMMEDIATE v_sql;
END IF;
END LOOP;
CLOSE C1;
END;