sql
Add Unique Constraints on Column in MySQL
-- WHILE CREATING TABLE ON SINGLE COLUMN
CREATE TABLE table_name(
column_name_1 data_type UNIQUE
);
-- OR YOU CAN ADD LIKE BELOW
CREATE TABLE table_name(
column_name_1 data_type,
UNIQUE(column_name_1)
);
-- ADD BY COMBINING MORE THAN ONE COLUMN WHILE CREATING TABLE
CREATE TABLE table_1(
column_name_1 data_type,
column_name_2 data type,
UNIQUE(column_name_1,column_name_2)
);
Was this helpful?
Similar Posts
- Add unique key constraint on existing column Sql query
- Increase or decrease column value counter in Mysql
- Reset AUTO_INCREMENT Column value MySql
- SQL query to copy one column values to another column in same table
- Create or update records Mysql/Sql
- MySQL Foreign key constraint
- Insert data from one table to another in MySql