Answers for "create table and constraints sql"

SQL
0

sql server create constraint

ALTER TABLE my_table ALTER COLUMN [Name] VARCHAR(50) NOT NULL;
ALTER TABLE my_table ADD CONSTRAINT UQ__Constrai UNIQUE (ID);
ALTER TABLE my_table ADD PRIMARY KEY (ID);
-- Get constraints names
SELECT CONSTRAINT_NAME,
     TABLE_SCHEMA ,
     TABLE_NAME,
     CONSTRAINT_TYPE
     FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
   WHERE TABLE_NAME='my_table';
ALTER TABLE my_table DROP CONSTRAINT PK__Constrai__xxxxx;
Posted by: Guest on April-17-2021
2

constraints in sql

RULES ABOUT THE COLUMNS IN TABLE
NOT NULL 	 # Ensures a column cannot have a NULL value
UNIQUE 		 # Ensures all values in a column are unique
PRIMARY KEY  # Identifies a record in a table, is NOT NULL & UNIQUE
FOREIGN KEY  # References a unique record from another table
CHECK		 # Ensures all column values satisfy a condition
DEFAULT		 # Set a default value for a column if none is entered
INDEX		 # Quick way of retrieving records from database
Posted by: Guest on January-07-2021

Code answers related to "create table and constraints sql"

Code answers related to "SQL"

Browse Popular Code Answers by Language