源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

oracle删除已存在的表的实例

  • 时间:2020-03-22 18:22 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:oracle删除已存在的表的实例
Sql代码
[u]复制代码[/u] 代码如下:
select count(*) from user_objects where object_name=upper(p_table_name);  select count(*) from user_tables where table_name=upper(p_table_name);  create or replace procedure p_drop_table_if_exist_v1(  p_table_name in varchar2  ) is  v_count number(10);  begin  select count(*)  into v_count  from user_objects  where object_name=upper(p_table_name);  if v_count > 0 then  execute immediate 'drop table ' || p_table_name || ' purge';  end if;  exception  when no_data_found then      begin          null;      end;  end;  /   create or replace procedure p_drop_table_if_exist_v2(  p_table_name in varchar2  ) is  v_table_name varchar2(20);  begin  select table_name   into v_table_name   from user_tables   where table_name=upper(p_table_name);  if length(v_table_name)>0 then    execute immediate 'drop table ' || p_table_name || ' cascade constraints';   end if;  exception  when no_data_found then      begin          null;      end;  end;  /  
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部