可以用create or replace的对象有:functions,procedures,packages,types,synonyms,triggerandviews,就是没有table,也没有sequence。 drop掉一个并不存在的表报错: SQL> drop table non_exists; drop table non_exists ORA-00942: 表或视图不存在 drop table容错的方法是: BEGIN DROP TABLE non_exists_table; EXCEPT...
create or replace procedure dropObject(ObjName varchar2,ObjType varchar2) is v_counter number := 0; begin if upper(ObjType) = 'TABLE' then select count(*) into v_counter from user_tables where table_name = upper(ObjName); if v_counter > 0 then execute immediate 'drop table ' || ...
oracle drop table if exists写法 文心快码BaiduComate 在Oracle数据库中,原生的SQL语法并不直接支持DROP TABLE IF EXISTS这种写法。然而,我们可以通过PL/SQL代码块来实现类似的功能。以下是详细的步骤和示例代码: 确认表是否存在: 我们可以使用SELECT COUNT(*)语句来检查表是否存在。如果返回的计数大于0,则表示表存在...
但是ORACLE里面没有像SQLSERVER那样的 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[HY_BSCDNM_J]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[HY_BSCDNM_J] GO CREATE TABLE ... 为避免总是要去点击SURE,所以参考了网上的方法,在创建临时表的...
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[HY_BSCDNM_J]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[HY_BSCDNM_J] GO CREATE TABLE ... 为避免总是要去点击SURE,所以参考了网上的方法,在创建临时表的时候,省去点击的麻烦。 待采集...
Oracle 的drop table if exists功能 Oracle创建表时,常遇到先删除后创建的情况,而它又没有drop table... if exists语法。为此可以使用user_objects数据字典和动态sql语句实现类似的功能,如下所示: create or replace procedure proc_dropifexists( p_table in varchar2...
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...
declarecnt number;begin---查询要创建的表是否存在selectcount(*)intocntfromuser_tableswheretable_name='STUDENTS';---如果存在则删除该表ifcnt>0thenexecuteimmediate'drop table STUDENTS';dbms_output.put_line('表存在,删除成功!');endif;---删除之后再创建该表executeimmediate'CREATE TABLE STUDENTS ...
CREATE OR REPLACE PROCEDURE DROPEXITSTABS (TAB_NAME_IN IN varchar2) IS v_cnt Number; begin select count(*) into v_cnt from user_tables where table_name = upper(TAB_NAME_IN); if v_cnt>0 then execute immediate 'drop table ' || TAB_NAME_IN ||' purge'; end If; end DROPEXITSTABS...
create new_table as select * from old_table; drop table old_table; 注意:表数据量大的话拉表很耽误时间,干掉老表也有可能影响某些正式运行的需要调用老表的job,有风险! 4:直接PLSQL 使用重建表(不推荐) 注意:重建表功能相当于 清掉所有数据 ,触发器,外键都会被清空,速度会很慢 ,效率并不是很好。