Oracle刪除表前判斷表名是否存在若存在則刪除

2022-09-24 14:24:15 字數 518 閱讀 8767

在oracle中若刪除乙個不存在mrzlypj的表,如 "drop table notexisttable",則會提示:

ora-00942:表或檢視不存在,

若使用程式執行該語句則會報異常,這就需要我們再刪除表前判斷該錶是否存在,若存在則刪除.

下面是不使用儲存過程實現刪除表的sql:

複製** **如下:

declare num number;

begin

select count(1) into num from user_tables where table_name = upper('tablename') ;

if num > 0 then

execute immediate 'drop程式設計客棧 table tablename' ;

end if;

end;程式設計客棧》

本文標題: oracle刪除表前判斷表名是否存在若存在則刪除

本文位址: /shujuku/oracle/101702.html

Oracle 修改表名

oracle修改表名的方式有以下幾種 方式一 1.先通過create table new table name as select from old table name 建立乙個新的表。2.檢查old table name上的約束,並把該約束應用到new table name上。3.禁用old t...

oracle刪除表的某個表分割槽 無法刪除表分割槽

刪除分割槽語句 alter table dws db.dws ccrm dim attr spec drop partition day id 20200207 丟擲如下異常 failed execution error,return code 1 from org.apache.hadoop.hi...

oracle 建立表,刪除表,修改表,查詢表

1,獲取當前使用者下的所有表資訊 select from user tables 1.1,查詢某一張表的字段資訊 select from user tab columns where table name 表名 1.2,查詢某一張表的注釋 select from user tab comments ...