Basic example of unique key in sql
Loading
Basic example of unique key in sql
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajanikant HawaldarPosted Nov 22, 2022, 1:28 PM
https://www.c-sharpcorner.com/article/sql-unique-constraint/
Vishal YelvePosted Nov 22, 2022, 11:29 AM
The UNIQUE Constraint prevents two records from having identical values in a column. In the CUSTOMERS table, for example, you might want to prevent two or more people from having an identical age.
Example
For example, the following SQL query creates a new table called CUSTOMERS and adds five columns. Here, the AGE column is set to UNIQUE, so that you cannot have two records with the same age.
If the CUSTOMERS table has already been created, then to add a UNIQUE constraint to the AGE column. You would write a statement like the query that is given in the code block below.
You can also use the following syntax, which supports naming the constraint in multiple columns as well.
DROP a UNIQUE Constraint
To drop a UNIQUE constraint, use the following SQL query.