Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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, [...]); 
Comment

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;
Comment

PREVIOUS NEXT
Code Example
Sql :: full sql mode 
Sql :: desc in sql 
Sql :: how to find the number of rows updated in oracle pl/sql 
Sql :: Cast for print sql 
Sql :: nullif postgresql 
Sql :: postgresql contains 
Sql :: mysql if null 
Sql :: sqlite get last 
Sql :: update join sql 
Sql :: ERROR 1046 (3D000): No database selected 
Sql :: mysql like case sensitive 
Sql :: mysql backup database 
Sql :: mysqldump with where clause 
Sql :: creating a table sql 
Sql :: Get first name and last name from full name string in SQL 
Sql :: inner join distinct 
Sql :: alter table myisam to innodb 
Sql :: sql query to select even numbers 
Sql :: mysql delete rows 
Sql :: mssql datetime to date 
Sql :: oracle array 
Sql :: drop CHECK constraint sql 
Sql :: mysql set boolean default value 
Sql :: sql stored procedure update if parameter is not null 
Sql :: SQL check if record exist 
Sql :: athena create table 
Sql :: into sql 
Sql :: sql select row with max date 
Sql :: sql where part of string match 
Sql :: SQL Subtraction Operator 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =