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

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 :: oracle sql timestamp 
Sql :: sous requete sql 
Sql :: mysql query unique column 
Sql :: create table mysql 
Sql :: sql alchemy with azuresql server 
Sql :: select count of distinct values sql 
Sql :: date 3 months from today sql 
Sql :: how to check schema privileges in oracle 
Sql :: mysql public key retrieval is not allowed 
Sql :: upper and lower in oracle sql 
Sql :: find difference in dates sql 
Sql :: t sql check column exists 
Sql :: use of now() in mysql 
Sql :: mysql db size 
Sql :: XOR in SQL Server 
Sql :: oracle exceeded simultaneous sessions_per_user limit 
Sql :: mysqli_connect using prepare statement 
Sql :: postgres create type 
Sql :: zsh: command not found: mysql mamp 
Sql :: mysql limit offset 
Sql :: sql create index 
Sql :: sql rank 
Sql :: shrink database file in sql server 
Sql :: postgres set default value 
Sql :: SQL Server Get the current identity value of the table 
Sql :: get name of day in sql 
Sql :: mysql ifnull 
Sql :: remove duplicates sql server select 
Sql :: create user sql server 
Sql :: sql decimal vs float 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =