Hi Friends,

Let's give a brief light on Constraints



Constraint:- It is the rule which restrict the incorrect data to be inserted into the database.
Types of Constraint:-
1.    Not Null Constraint
2.    Unique  Constraint
3.    Check  Constraint
4.    Primary Key Constraint
5.    Foreign Key Constraint
6.    Ref Key(Referential Kay) Constraint

TABLE LEVEL CONSTRAINT:-
COLUMN LEVEL CONSTRAINT:-
1.    NOT NULL:-This is the constraints will avoid null values to the column specified.
NOTE:- It is the only  constraint cannot be defined at Table level.

Syntax:-Create table <table_name>
(Empno NUMBER Constraint Empno_NN NOT NULL,
ENAME VARCHAR2(30) NOT NULL
);

SQL>  create table emp_info
  2   (
  3   empno number Constraint empno_pk Primary key,
  4   ename varchar2(20) Not Null,
  5   Job varchar2(20)   Constraint job_NN Not Null,
  6   MGR NUMBER Constraint mgr_ref References emp_info(empno),
  7   HIREDATE  Date,
  8   Sal Number Constraint sal_chk CHECK (sal Between 500 and 5500),
  9   comm Number,
 10   Deptno Number,
 11  Constraint deptno_fk FOREIGN KEY(deptno) References dept(deptno)
 12  );


Data Dictionary:-User_Constraints , User_cons_columns
 

Comments

Popular posts from this blog

How to Customize AP Invoice Approval in Oracle Fusion cloud Application using Business Process Management(BPM)