Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql alter table add column if exists

IF NOT EXISTS (
  SELECT
    *
  FROM
    INFORMATION_SCHEMA.COLUMNS
  WHERE
    TABLE_NAME = 'table_name' AND COLUMN_NAME = 'col_name')
BEGIN
  ALTER TABLE table_name
    ADD col_name data_type NULL
END;
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle sql log to console 
Sql :: sql database size 
Sql :: sql getdate date only 
Sql :: see all users mysql 
Sql :: linux command line import mysql database 
Sql :: mysql import ignore errors 
Sql :: rename table postgres 
Sql :: [2021-10-05T13:43:48.961Z] error Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client 
Sql :: cast to date bigquery 
Sql :: postgresql drop primary key constraint 
Sql :: sql check roles 
Sql :: postgresql if 0 then 1 
Sql :: how to get non distinct values in sql 
Sql :: psql lst trigger 
Sql :: oracle extract minute from date 
Sql :: mysql set field unique 
Sql :: delete a view sql 
Sql :: sql change table name 
Sql :: mysql check if string contains comma separated 
Sql :: sqlite create integer column with limit 
Sql :: check message id sql server 
Sql :: mysql subtract month from timestamp 
Sql :: sql syntax find few columns 
Sql :: mysql full outer join java 
Sql :: psql show with user is logged in 
Sql :: sql count columns 
Sql :: sql server query list all databases 
Sql :: access the postgres psql 
Sql :: select from array in psql 
Sql :: delete all table oracle 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =