oracle添加字段前先判斷字段是否已存在


declare n number;
begin
  select count(1) into n from  all_table_columns where table_name = upper('表名') and column_name = upper('字段名');
  if n = 0 then
  dbms.put_line('字段不存在');
  execute immediate 'alter table 表名 add 字段名 字段類型(長度)'
  if n > 0 then
    dbms_output.put_line('字段已存在');
  end if;
end;
/
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM