`

drop_table_if_exists.sql

 
阅读更多

CREATE OR REPLACE PROCEDURE drop_table_if_exists(tableName VARCHAR2)
IS
  table_nums NUMBER(2);
BEGIN
     SELECT COUNT(1) INTO table_nums FROM user_tables WHERE table_name=UPPER(tableName);
     IF table_nums > 0 THEN
        EXECUTE IMMEDIATE 'DROP TABLE ' || tableName || ' CASCADE CONSTRAINTS';
     END IF;
END;
/

分享到:
评论

相关推荐

    mantis db_generate.sql

    DROP TABLE IF EXISTS mantis_bug_table; CREATE TABLE mantis_bug_table ( id int(7) unsigned zerofill DEFAULT '0000000' NOT NULL auto_increment, reporter_id int(7) unsigned zerofill DEFAULT '0000000' ...

    Sql2000_test.rar_Go_ Go_ Go!_SQL Stress Tes_delphi 邮件_sqlstress

    if exists (select * from dbo.sysobjects where id = object_id(N [dbo].[StuInfo] ) and OBJECTPROPERTY(id, N IsUserTable ) = 1) drop table [dbo].[StuInfo] GO CREATE TABLE [dbo].[StuInfo] ( [StuID] ...

    DROP TABLE在不同数据库中的写法整理

    DROP TABLE IF EXISTS [table_name] 2,Oracle中: BEGIN EXECUTE IMMEDIATE 'DROP TABLE [table_name]'; EXCEPTION WHEN OTHERS THEN NULL; END; 3,在Sql Server中 IF EXISTS ( SELECT TABLE_NAME FROM ...

    oracle数据库学习笔记总结

    二、常用SQL: ... SQL Server的: IF EXISTS (SELECT name FROM sysobjects WHERE name = '表名' AND type = 'U') DROP TABLE 表名; Oracle的: create or replace table 表名 ...; -- 直接写建表语句

    sql 数据库程序设计

    if exists (select 1 from sysindexes where id = object_id('员工基本信息') and name = '属于_FK' and indid > 0 and indid ) drop index 员工基本信息.属于_FK go if exists (select 1 from sysindexes ...

    Industry_upload.sql

    DROP TABLE IF EXISTS `industry`; CREATE TABLE `industry` ( `code` varchar(255) COLLATE utf8_bin DEFAULT NULL, `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, `pid` varchar(11) COLLATE utf8_bin ...

    2020尚硅谷 谷粒商城 建表sql语句

    drop table if exists pms_attr; drop table if exists pms_attr_attrgroup_relation; drop table if exists pms_attr_group; drop table if exists pms_brand; drop table if exists pms_category; drop table...

    china_area_2.sql

    DROP TABLE IF EXISTS `china_area`; CREATE TABLE `china_area` ( `id` int(8) NOT NULL AUTO_INCREMENT, `area_id` int(11) unsigned DEFAULT '0' COMMENT '自身id', `parent_id` int(11) unsigned DEFAULT '0'...

    PKXT.sql的sql文件

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Actor]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[Actor] GO if exists (select * from dbo.sysobjects ...

    core_areacode.sql

    DROP TABLE IF EXISTS `core_areacode`; CREATE TABLE `core_areacode` ( `province` varchar(255) DEFAULT NULL COMMENT '省', `city` varchar(255) DEFAULT NULL COMMENT '市', `area_code` varchar(255) ...

    mysql 100万1000万条数据表的生成,t100w.sql导入文件

    DROP TABLE IF EXISTS `t100w`; CREATE TABLE `t100w` ( `id` int(11) DEFAULT NULL, `num` int(11) DEFAULT NULL, `k1` char(2) COLLATE utf8mb4_bin DEFAULT NULL, `k2` char(4) COLLATE utf8mb4_bin DEFAULT...

    heima_leyou_new.zip

    DROP TABLE IF EXISTS `tb_spec_group`; CREATE TABLE `tb_spec_group` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `cid` bigint(20) NOT NULL COMMENT '商品分类id,一个分类下有多个规格组', ...

    history.sql

    DROP TABLE IF EXISTS `history`; CREATE TABLE `history` ( `id` int(0) NOT NULL AUTO_INCREMENT, `year` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `month` varchar(255) ...

    android数据库

    private static class DBOpenHelper extends SQLiteOpenHelper { // 继承SQLITEOpenHelper的静态内部类 private static final String ... _db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE); onCreate(_db); } }

    area_insert_quanguo.sql

    DROP TABLE IF EXISTS `area`; CREATE TABLE `area` ( `id` bigint(20) NOT NULL COMMENT 'ID', `name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '区域名称', `pid` bigint(20)...

    mysql提示[Warning] Invalid (old?) table or database name问题的解决方法

    DROP TABLE IF EXISTS [TEMP_TABLE_NAME]; create temporary table [TEMP_TABLE_NAME] select col1,col2,… from [TABLE_NAME]; alter table [TEMP_TABLE_NAME] add unique idx_col1(col1); 经过以上操作中,多次...

    sql添加表列字段描述添加默认值删除字段

    if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Table1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) create table [Table1] ([col1] int,[col2] int) //添加字段 if not exists...

    Access_JDBC30 无使用次数限制 - 破解

    statement.execute("drop table if exists test;"); statement.execute("create table if not exists test(field1 varchar(25),field2 varchar(25),field3 varchar(25),field4 varchar(25),field5 varchar(25),...

    基础知识-SQL.doc

    drop table WL go create table WL ( WL_WLID char(20) not null default(''), WL_MC char(40) null default(''), WL_JLDW char(4) null default(''), WL_ABC char(1) null default(''), WL_KCSL float null ...

    图书管理系统--SQL server 2000后台数据库处理

    if exists (select * from dbo.sysdatabases where name = 'library') drop database library GO create database library go use library go if exists (select * from dbo.sysobjects where id = object_id(N'...

Global site tag (gtag.js) - Google Analytics