Search
 
SCRIPT & CODE EXAMPLE
 

SQL

alter table

ALTER TABLE table_name MODIFY column_name datatype NOT NULL;
Comment

alter table

ALTER TABLE table_name MODIFY COLUMN column_name datatype;
Comment

sql alter column

Changes the data type of a table’s column.
Example: In the ‘users’ table, make the column ‘incept_date’ into a
‘datetime’ type.
ALTER TABLE users
ALTER COLUMN incept_date datetime;
Comment

ALTER IN SQL

ALTER TABLE DataFlair
ADD emp_id varchar(5);
Comment

sql alter table

-- With check if field already exists

IF NOT EXISTS(SELECT 1 FROM sys.columns 
          WHERE Name = N'Email'
          AND Object_ID = Object_ID(N'dbo.Customers'))
BEGIN    
	ALTER TABLE Customers
    ADD Email varchar(255);
END
Comment

alter table

ALTER TABLE table_name 
DROP PRIMARY KEY;
Comment

alter table

ALTER TABLE table_name 
ADD CONSTRAINT MyUniqueConstraint CHECK (CONDITION);
Comment

alter table

ALTER TABLE table_name 
DROP CONSTRAINT MyUniqueConstraint;
Comment

alter table

ALTER TABLE table_name 
ADD CONSTRAINT MyPrimaryKey PRIMARY KEY (column1, column2...);
Comment

alter table

ALTER TABLE table_name 
ADD CONSTRAINT MyUniqueConstraint UNIQUE(column1, column2...);
Comment

alter table

ALTER TABLE table_name 
DROP INDEX MyUniqueConstraint;
Comment

PREVIOUS NEXT
Code Example
Sql :: psql invalid command N 
Sql :: sql query print strings and int 
Sql :: sql creating tables 
Sql :: sql constraint to check date less than current date 
Sql :: select only columns that are not empty oracle sql 
Sql :: example database query 
Sql :: timestamp to date sql server 
Sql :: mysql set column equal to another automatic 
Sql :: postgresql sum 
Sql :: sql: extract day text from datetime value 
Sql :: how to save postgresql query 
Sql :: drop table oracle 
Sql :: end mysql command 
Sql :: table users 
Sql :: apex for oracle 11g 
Sql :: not null sql 
Sql :: sql select without column name 
Sql :: how to output a different column name in mysql 
Sql :: mysql --version 
Sql :: Should I use the datetime or timestamp data type in MySQL? 
Sql :: create procedure sql 
Sql :: create table if not exist 
Sql :: how do you insert boolean to postgresql 
Sql :: duplicate a column in sql 
Sql :: recourse record format 
Sql :: sqlcmd xml output insert line break after every 2033 characters 
Sql :: ORACLE: How to get all column with GROUP by only 1 column? 
Sql :: show blank in column if condition not matches in join mysql 
Sql :: oracle synonym package dblink 
Sql :: sql create text column limited values 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =