Home >Database >Mysql Tutorial >oracle的drop table if exists

oracle的drop table if exists

WBOY
WBOYOriginal
2016-06-07 15:02:359081browse

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 oracle的drop table if exists Sql代码 利用存储实现 create or replace procedure proc_dropifexists( p_table in varchar2 ) is v_count number(10); begin select count(*) into v_count

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

    oracle的drop table if exists

    Sql代码

    利用存储实现

    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的drop table if exists

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn