ORACLE 增加两列字段


declare v_cnt number;
 V_SQL VARCHAR2 (500) := '';
begin
 select count(*) into v_cnt from dual where exists(SELECT * FROM USER_TAB_COLUMNS WHERE TABLE_NAME = UPPER('TB_FDN_DEVICEACCOUNT') AND COLUMN_NAME = 'NSBFL');
   if v_cnt = 0 then
    V_SQL := 'ALTER TABLE TB_FDN_DEVICEACCOUNT ADD NSBFL NVARCHAR2(50)';
    EXECUTE IMMEDIATE V_SQL;
    V_SQL := 'comment on column TB_FDN_DEVICEACCOUNT.NSBFL is ''原设备分类''';
    EXECUTE IMMEDIATE V_SQL;
end if;
 select count(*) into v_cnt from dual where exists(SELECT * FROM USER_TAB_COLUMNS WHERE TABLE_NAME = UPPER('TB_FDN_DEVICEACCOUNT') AND COLUMN_NAME = 'NSBLX');
   if v_cnt = 0 then
    V_SQL := 'ALTER TABLE TB_FDN_DEVICEACCOUNT ADD NSBLX NVARCHAR2(50)';
    EXECUTE IMMEDIATE V_SQL;
    V_SQL := 'comment on column TB_FDN_DEVICEACCOUNT.NSBLX is ''原设备类型''';
    EXECUTE IMMEDIATE V_SQL;
end if;
end;

posted @ 2017-04-28 09:26  萌橙  阅读(1063)  评论(0编辑  收藏  举报