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 :: uninstall mysql server ubuntu 
Sql :: change month to name in sql server 
Sql :: search query in mysql 
Sql :: importance of comment in mysql 
Sql :: sql server loop over query 
Sql :: return sql query laravel 
Sql :: helptext in sql 
Sql :: laravel paginate raw sql 
Sql :: alter table change default 
Sql :: mysql default port 
Sql :: how to delete table in mysql 
Sql :: replace null with 0 in sql 
Sql :: psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user 
Sql :: sql insert timestamp 
Sql :: login to database mysql terminal 
Sql :: mariadb number format 
Sql :: alter table 
Sql :: how to select all attributes from a row if there is a certain string in it MySQL 
Sql :: how to add foreign key constraint in sql 
Sql :: add new column not null sql server 
Sql :: mysql data types 
Sql :: fetch first 5 characters of the string in sql 
Sql :: restore postgres database from sql file 
Sql :: make a field auto_increment mysql 
Sql :: how to create table in sql 
Sql :: MySQL shutdown unexpectedly. 
Sql :: t sql to rebuild all indexes in a database 
Sql :: insert query in ci 
Sql :: shrink database file in sql server 
Sql :: ora-01109 database not open in oracle 19c 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =