DB2 Drop table if exists equivalent

后端 未结 5 2160
既然无缘
既然无缘 2020-12-18 23:07

I need to drop a DB2 table if it exists, or drop and ignore errors.

5条回答
  •  遥遥无期
    2020-12-18 23:38

    search on systable : if you are on as400 (power i, system i) the system table name is QSYS2.SYSTABLES else try sysibm.systables or syscat.tables (This depends on the operating system)

    BEGIN    
    IF EXISTS (SELECT NAME FROM QSYS2.SYSTABLES WHERE TABLE_SCHEMA = 'YOURLIBINUPPER' AND TABLE_NAME = 'YOUTABLENAMEINUPPER') THEN           
      DROP TABLE YOURLIBINUPPER.YOUTABLENAMEINUPPER;                             
    END IF;                                                        
    END  ; 
    

提交回复
热议问题