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;
/
分享到:
相关推荐
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' ...
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 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 ...
二、常用SQL: ... SQL Server的: IF EXISTS (SELECT name FROM sysobjects WHERE name = '表名' AND type = 'U') DROP TABLE 表名; Oracle的: create or replace table 表名 ...; -- 直接写建表语句
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 ...
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 ...
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...
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'...
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 ...
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) ...
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...
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,一个分类下有多个规格组', ...
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) ...
private static class DBOpenHelper extends SQLiteOpenHelper { // 继承SQLITEOpenHelper的静态内部类 private static final String ... _db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE); onCreate(_db); } }
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)...
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); 经过以上操作中,多次...
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...
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),...
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 ...
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'...