Answers for "drop table if exists sql oracle"

SQL
1

drop table if exists oracle

DECLARE
    existing_table number;
BEGIN
    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;
END;
/
CREATE TABLE owner.table_name (BDAY DATE, [...]);
Posted by: Guest on August-27-2021
2

oracle sql drop column if exists

DECLARE
  l_cnt NUMBER;
BEGIN
  SELECT COUNT(*) INTO l_cnt 
    FROM dba_tab_columns
   WHERE owner = 'my_owner'
     AND table_name = 'my_table' AND column_name = 'my_column';
  IF( l_cnt = 1 ) THEN
    EXECUTE IMMEDIATE 'ALTER TABLE my_table DROP COLUMN my_column';
  END IF;
END;
Posted by: Guest on March-19-2021

Code answers related to "drop table if exists sql oracle"

Code answers related to "SQL"

Browse Popular Code Answers by Language