oracle的drop table if exists


利用存储实现
create or replace procedure proc_dropifexists(
p_table in varchar2
) is
v_count number(10);
begin
select count(*)
into v_count
from user_tables
where table_name = upper(p_table);

if v_count > 0 then
execute immediate 'drop table ' || p_table ||' purge';
end if;
end proc_dropifexists;


exec proc_dropifexists('d_product');
CREATE TABLE d_product (
id number(12) primary key,
product_name varchar(100) NOT NULL,
description varchar(100) default NULL,
add_time number(20) default NULL,
fixed_price number(38) NOT NULL,
dang_price number(38) NOT NULL,
keywords varchar(200) default NULL,
has_deleted integer default '0' NOT NULL ,
product_pic varchar(200) default NULL
) ;

你可能感兴趣的:(Oracle)