drop table if exists oracle 1

drop table if exists oracle

    existing_table number;
    SELECT count(*) into existing_table FROM ALL_TABLES
    WHERE TABLE_NAME = 'table_name' AND OWNER = 'owner';
    IF existing_table = 1 then
        EXECUTE IMMEDIATE 'DROP TABLE owner.table_name';
    END IF;
CREATE TABLE owner.table_name (BDAY DATE, [...]); 

Here is what the above code is Doing:
1. Declaring a variable called existing_table
2. Checking if the table exists
3. If it does, drop it
4. Create the table

Similar Posts