Search
 
SCRIPT & CODE EXAMPLE
 

SQL

create table if not exists sql

CREATE TABLE IF NOT EXISTS

> CREATE TABLE IF NOT EXISTS TEAMS
> (TEAMNO      INTEGER NOT NULL PRIMARY KEY,
> EmployeeNO    INTEGER NOT NULL,
> DIVISION    CHAR(6) NOT NULL);
Comment

SQL CREATE TABLE IF NOT EXISTS

CREATE TABLE IF NOT EXISTS Companies (
  id int,
  name varchar(50),
  address text,
  email varchar(50),
  phone varchar(10)
);
Comment

create table if not exists

create table if not exists schema_uploadfile.tbl_uploadfile(
	id serial primary key,
	file_name varchar(255) unique,
	file_type varchar(30),
	grp_data bytea
);
Comment

Create table if not exist

declare
nCount NUMBER;
v_sql LONG;

begin
SELECT count(*) into nCount FROM dba_tables where table_name = 'EMPLOYEE';
IF(nCount <= 0)
THEN
v_sql:='
create table EMPLOYEE
(
ID NUMBER(3),
NAME VARCHAR2(30) NOT NULL
)';
execute immediate v_sql;

END IF;
end;
Comment

Create table if not exist with exceptions

declare
v_sql LONG;
begin

v_sql:='create table EMPLOYEE
  (
  ID NUMBER(3),
  NAME VARCHAR2(30) NOT NULL
  )';
execute immediate v_sql;

EXCEPTION
    WHEN OTHERS THEN
      IF SQLCODE = -955 THEN
        NULL; -- suppresses ORA-00955 exception
      ELSE
         RAISE;
      END IF;
END; 
/
Comment

PREVIOUS NEXT
Code Example
Sql :: SQL Syntax of FULL OUTER JOIN 
Sql :: mysql even numbers 
Sql :: SQL/delete 
Sql :: .env pgsql 
Sql :: postgresql like 
Sql :: import mysql command line 
Sql :: java.sql.sqlexception: the url cannot be null 
Sql :: sql limit clause 
Sql :: cast as decimal postgresql 
Sql :: mysql max connections exceeded max_connections_per_hour 
Sql :: import Data in MySQL without using any other software 
Sql :: SQL Comments Within Statements 
Sql :: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails 
Sql :: WHERE value IS sql 
Sql :: pl sql command line run 
Sql :: Kill session in SQL Developer 
Sql :: ubuntu install mysql 5.7 
Sql :: show create table in postgresql 
Sql :: mysql shell set time_zone 
Sql :: select columns from 2 tables with foreign key 
Sql :: psql owner of database 
Sql :: search from comma separated values in sql server 
Sql :: sql stored procedure output parameters 
Sql :: add column mysql 
Sql :: execution time of mysql query 
Sql :: group_concat sql server 
Sql :: select from table and insert into table in sql 
Sql :: sql select condition with left join 
Sql :: salesforce soql get parents without children 
Sql :: how to list all values of a column that start with a letter in sql 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =