oracle建表如果存在先刪除 oracle創(chuàng)建表之前判斷表是否存在,如果存在則刪除已有表?
oracle創(chuàng)建表之前判斷表是否存在,如果存在則刪除已有表?1、創(chuàng)建刪表函數(shù),createorreplaceproceduredrop_table(tbl_namevarchar2)as v_cntn
oracle創(chuàng)建表之前判斷表是否存在,如果存在則刪除已有表?
1、創(chuàng)建刪表函數(shù),createorreplaceproceduredrop_table(tbl_namevarchar2)as v_cntnumber begin selectcount(*)intov_cntfromuser_tablestwheretable_name=upper(tbl_name) --如果存在則刪除 ifv_cnt>0then executeimmediate"droptable"||tbl_name||"purge" dbms_output.put_line("刪除表("||tbl_name||")成功") else dbms_output.put_line("表("||tbl_name||")未建") endifend2、編譯該函數(shù),是函數(shù)可以正常執(zhí)行,3、測(cè)試函數(shù),輸入不存在的表名test_aaa4、查看輸出窗口,為,表未建,5、再次測(cè)試函數(shù),輸入存在的表名,6、查看輸出窗口,表已刪除,
oracle創(chuàng)建表之前判斷表是否存在,如果存在則刪除已有表?
按照你的描述可以用range分區(qū)"alter table 表名 add partition 分區(qū)名字 values less than 值 tablespace 表空間" 例子:alter table test1 add partition P20160501 values less than (to_date("20160601","yyyymmdd")) tablespace S2------這樣就可以加入5月份的分區(qū)
Oracle如何判斷是否存在某張表?
在ORACLE中可以通過查詢數(shù)據(jù)字典判斷.如果判斷當(dāng)前模式下是否存在,可以查user_tablesifexists(select1fromuser_tableswheretable_name="表名")......如果判斷所有模式下是否存在,則需要連接system或者sys.然后查user_tablesconnsystem/密碼(或者connsys/密碼assysdba)ifexists(select1fromdba_tableswheretable_name="表名")......注意:以上表名全部需要用大寫字母.省略號(hào)表示判斷之后需要執(zhí)行的語句.