Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Adding Unique constraint on the column

 

1. Connect to MySQL:

Use a MySQL client or command-line tool to connect to your MySQL server. You will need appropriate privileges to modify the table structure.

mysql -u <USERNAME> -p

2. Select the Database:

Choose the database where your table is located.

USE <DB_NAME>;

3. Identify the Table:

Identify the table and column for which you want to add a unique constraint.

4. Add Unique Constraint:

Use the ALTER TABLE statement to add a unique constraint to the specified column.

alter table <TABEL_NAME> add constraint <CONSTRAINT_NAME> unique (<COLUMN_NAME>);

 

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com