Explain the constraints that can be applied to Oracle tables

Explain the constraints that can be applied to Oracle tables.

Oracle constraints are usually used to maintain integrity of data. The different types of constraints include:-

CHECK constraint: This constraint specifies a condition for a row.
Example:
Create table employee
(
Id, varchar(10),
CONSTRAINT id
CHECK (id BETWEEN 10 and 1000)
);

NOT NULL constraint: This specifies that a column cannot accept NULL values.
Example:
Create table employee
(
Id, varchar(10) NOT NULL,
CONSTRAINT id
CHECK (id BETWEEN 10 and 1000)
);

Primary key constraint: This constraint ensures that each row is identified by a unique key.
Example:
Create table employee
(
Id, varchar(10) NOT NULL,
Roll_number INTEGER(10);
CONSTRAINT id PRIMARY KEY(Roll_number)
);

Unique Constraint: This constraint ensures no columns value has repetitive values.
Example:
Create table employee
(
Id, varchar(10) NOT NULL,
Roll_number INTEGER (10);
CONSTRAINT id UNIQUE (Roll_number)
);

Explain the constraints that can be applied to Oracle tables.

The syntax of writing a table is
create table tablename ( columnname type, columnname type ..., primary key(keycolumn);

The keycolumn is associates with the key constraint.

You can even add the foreign key constraint by adding the references to the table for that foreign key in the following way:
foreign key(column) references foreigntable
Types of constraints in Oracle
Not Null Constraint, Primary Key Constraint, References Constraint, Unique Constraint...
What is an integrity constraint?
Integrity constraints define a business rule for a column of the table. They are defined with a table and are stored as part of a table’s definition....
Oracle nested table and varrays
Oracle nested table and varrays - What is nested table? Explain the purpose of nested table - A nested table is an unordered set of data elements. These data elements are all of the same datatype.....
Post your comment