Oracle: Drop table / column if it exists
DECLARE
table_exists NUMBER :=0;
–column_exists NUMBER :=0;
BEGIN
–Drop table / column if it exists
SELECT COUNT(*) INTO table_exists FROM USER_TABLES WHERE TABLE_NAME = ‘
–SELECT COUNT(*) INTO column_exists ALL_TAB_COLUMNS WHERE OWNER = ‘
IF table_exists > 0 THEN
EXECUTE IMMEDIATE(‘DROP TABLE
END IF;
END;
/
CREATE TABLE
(
LOAD_ID NUMBER,
YEAR_MONTH VARCHAR2(6 CHAR),
ORDER_ID NUMBER (15,0),
ORDER_STATUS VARCHAR2(20 CHAR),
CP_CODE VARCHAR2(30 CHAR),
CREATED DATE,
MODIFIED DATE,
IMAGE_DATE DATE
)