oracle判断字段是否存在语句

declare v_cnt number;
begin
        select count(*) into v_cnt from dba_tab_columns where table_name='T_IDC_FUNCTION' and column_name='TEST1';
        if v_cnt = 0 then
          execute immediate 'alter table t_idc_function add test1 varchar(40)';  
          null;--IF语句里面必须至少一行SQL语句,所以当没有任何语句的时候,可以添加这一句
        end if;
end;

 

posted @ 2015-02-12 15:02  屌丝大叔的笔记  阅读(1363)  评论(0编辑  收藏  举报