You are on page 1of 2

3/25/2020 SQL - UNIQUE Constraint | 1Keydata

SQL Unique Constraint

Create A Website     SQL     Data Warehousing     CSS     PHP     HTML     Database Normalization

SQL Tutorial
Basic SQL Commands
SQL SELECT
SQL DISTINCT
Data and Schema Comparison
SQL WHERE Data & Schema Compare and Synchronization for 16 DBMS's
SQL AND OR
SQL IN
SQL BETWEEN
dbbest.com OPEN
SQL Wildcard
SQL LIKE
SQL ORDER BY
SQL GROUP BY
SQL > Constraint > UNIQUE Constraint
SQL HAVING
SQL ALIAS
The UNIQUE constraint ensures that all values in a column are distinct.
SQL AS
SQL SELECT UNIQUE For example, in the following CREATE TABLE statement,
SQL JOIN
SQL INNER JOIN CREATE TABLE Customer
SQL OUTER JOIN (SID integer UNIQUE,
Last_Name varchar (30),
SQL LEFT OUTER JOIN
First_Name varchar(30));
SQL CROSS JOIN
SQL INSERT INTO
column "SID" has a UNIQUE constraint, and hence cannot include duplicate values. Such constraint does not
SQL INSERT INTO SELECT
hold for columns "Last_Name" and "First_Name". So, if the table already contains the following rows:
SQL UPDATE
SQL DELETE FROM SID Last_Name First_Name
Advanced SQL 1 Johnson Stella
SQL UNION 2 James Gina
SQL UNION ALL 3 Aaron Ralph
SQL Inline View
SQL INTERSECT Executing the following SQL statement,
SQL MINUS
SQL LIMIT INSERT INTO Customer VALUES (3, 'Lee', 'Grace');
SQL TOP
SQL Subquery will result in an error because '3' already exists in the SID column, thus trying to insert another row with that
SQL EXISTS value violates the UNIQUE constraint.
SQL CASE
Please note that a column that is speci ed as a primary key must also be unique. At the same time, a column
SQL DECODE
that's unique may or may not be a primary key. In addition, multiple UNIQUE constraints can be de ned on a
SQL AUTO INCREMENT
table.
SQL IDENTITY
SEQUENCE & NEXTVAL Next: SQL CHECK Constraint
SQL Functions
SQL Average
SQL COUNT
SQL MAX
SQL MIN
SQL SUM
SQL ROUND

String Functions
SQL CAST
SQL CONVERT
SQL CONCATENATE
SQL SUBSTRING
SQL INSTR Copyright © 2020   1keydata.com   All Rights Reserved     Privacy Policy     About   Contact
SQL TRIM
https://www.1keydata.com/sql/sql-unique.html 1/2
3/25/2020 SQL - UNIQUE Constraint | 1Keydata
SQL TRIM
SQL LENGTH
SQL REPLACE
SQL TO_DATE

https://www.1keydata.com/sql/sql-unique.html 2/2

You might also like