CREATE A TABLE

CREATE TABLE EMPLOYEE(

EMPLOYEE_NUMBER DECIMAL(4,0),

EMPLOYEE_FIRST_NAME VARCHAR2(50),

);

 

ADDING Contrainsts to a Table During Creation

Adding contrainsts to the entire table at creation in called an out of line constraint. That is because constraints are not added to individual columns.

CREATE TABLE TBL_TRANSACTION2(
AMOUNT NUMBER(15,2) NOT NULL,
DATEOFTRANSACTION DATE NOT NULL,
EMPLOYEENUMBER NUMBER(4,0) NOT NULL,
CONSTRAINT UNIQUETRANSACTION UNIQUE (AMOUNT, DATEOFTRANSACTION,EMPLOYEENUMBER)
) ;

Adding Inline Constrainsts During Table Creation

CREATE TABLE TBL_TRANSACTION2(
AMOUNT NUMBER(15,2) NOT NULL,
DATEOFTRANSACTION DATE NOT NULL,
EMPLOYEENUMBER NUMBER(4,0) NOT NULL CONSTRAINT UNIQUETRANSACTION UNIQUE,--- inline constraint
CONSTRAINT UNIQUETRANSACTION UNIQUE (AMOUNT, DATEOFTRANSACTION,EMPLOYEENUMBER) --- out of line constraint is used for multiple columns.
) ;

learn more about constrainsts

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top