SQL UNIQUE Constraint
Constraints are rules that the SQL server database engine applies to you. Standard example, you can use UNIQUE constraints to ensure that no twofold value is entered into specific columns that do not participate in a primary key.
Although a UNIQUE constraint and a PRIMARY CLE constraint apply uniqueness, use a UNIQUE constraint instead of a PRIMARY CLE constraint when you want to apply the uniqueness of a column, or a combination of columns, this is not the main key.
Unlike KEY PRIMAIRES constraints, UNIQUE constraints allow null value. However, as with any member value at a SINGLE constraint, only one zero value is allowed standard column.
A UNIQUE constraint can be referenced standard a FOREIGN KEY constraint.
When a UNIQUE constraint is added to an existing column or columns in the scene, standard defect, the database engine looks at the existing data in the columns to ensure that all values are unique.
If a UNIQUE constraint is added to a column that has duplicate values, the database engine returns an error and does not add stress.
The database engine automatically creates a UNIQUE list to enforce the uniqueness requirement of the UNIQUE constraint.
Standard therefore, if a conditional to insert a line in twofold is made, the database engine returns an error message that indicates that the UN CONSTRAINT has been violated and does not add the line to the table.
Unless a grouped list is explicitly specified, an exceptional and uncluded record is created standard default to enforce the UN CONSTRAINT.
The UNIQUE constraint ensures that all the values of a column are different.
The UNIQUE and PRIMARY KEY constraints ensure the uniqueness of a column or an outfit of columns.
A PRIMARY CLE constraint automatically a UNIQUE constraint.
However, you can have many unique standard table constraints, but only one standard PRIMARY table CLE constraint.
SQL create constraints
The constraints can be specified when the scene is created with the CREATE TABLE statement, or after creating the table with the ALTER TABLE statement.
Syntax UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
CREATE TABLE table_name (
column_Name_01 datatype constraint,
column_Name_02 datatype constraint,
column_Name_03 datatype constraint,
....
);UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
Constraint SQL on THE CREATE TABLE UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
CREATE TABLE PERSON(
NAME varchar2(20) UNIQUE,
Age Number NOT NULL,
Hobbies Varchar2(20) NOT NULL UNIQUE,
TEL varchar2(20),
);UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
Constraint UNIQUE on ALTER TABLE UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
Syntax UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
Example UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE
To create a UNIQUE constraint on the "TEL" column when the table is already created, use the following SQL:UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
ALTER TABLE PERSON ADD UNIQUE (TEL);
UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE
DROP an UNIQUE constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE
To drop a UNIQUE constraint, use the following SQL:UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
Syntax UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
ALTER TABLE TABLE_NAME DROP CONSTRAINT (Column_Name);UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
Example
ALTER TABLE PERSON DROP CONSTRAINT (NAME);Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint UNIQUE Constraint
0 Comments