mysql中如果表存在则删除有语句:drop table if exists schema.table; 但是oracle并不支持这样的语句,可以自己用procedure来实现。亲测有效。 创建procedure来实现drop table if exists schema.table; --/createorreplaceprocedurejoe.PROC_DROPTABLEIFEXISTS(p_tableinvarchar2)ast_countnumber(10);beginselectcount(*)...
if v_count > 0 then execute immediate 'drop table ' || p_table ||' purge'; end if; end; / --调用 exec proc_dropifexists('mytable');
SQL> drop table non_exists; drop table non_exists ORA-00942: 表或视图不存在 drop table容错的方法是: BEGIN DROP TABLE non_exists_table; EXCEPTION WHEN OTHERS THEN IF sqlcode != -0942 THEN RAISE; END IF; END; drop sequence容错的方法是: BEGIN DROP SEQUENCE non_exists_sequence; EXCEPTION WH...
类似dorp table if exists,语句可反复执行 开发人员编写sql,让实施人员执行 直接写drop table abc,如果abc表已经被删除或者不存在,返回报错信息,对于不懂sql的实施人员来说,会产生干扰 1. 2. 3. 4. 5. 代码示例 创建存储过程 适用于drop table, procedure, function, trigger, view, sequence ...
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, ...
5 Oracle SQL - If Exists, Drop Table & Create 1 How can drop table if table exists in oracle? 0 oracle drop table if doesn't exist (in one line) 1 Drop table with condition - Oracle 0 Oracle function to drop table if exists 0 Oracle SQL only drop a column if a table exis...
DROP TABLE IF EXISTS sys_area; CREATE TABLE sys_area ( id int NOT NULL AUTO_INCREMENT COMMENT '编号', parent_id varchar(64) NOT NULL COMMENT '父级编号', parent_ids varchar(2000) NOT NULL COMMENT '所有父级编号', name varchar(100) NOT NULL COMMENT '名称', ...
DROP TABLE IF EXISTS sys_area; CREATE TABLE sys_area ( idintNOT NULL AUTO_INCREMENT COMMENT'编号', parent_id varchar(64) NOT NULL COMMENT'父级编号', parent_ids varchar(2000) NOT NULL COMMENT'所有父级编号', name varchar(100) NOT NULL COMMENT'名称', ...
DROP TABLE IF EXISTS [table_name] Oracle: BEGIN EXECUTE IMMEDIATE 'DROP TABLE [table_name]'; EXCEPTION WHEN OTHERS THEN NULL; END; 1. SQL Server: IF EXISTS ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '[table_name]') DROP TABLE [table_name] ...