difference between table level constraint and column level and
advantages of table level constraint

Answer Posted / anil

ANS:
COLUMN LEVEL CONSTRAINT
If we provide constraint along with column while creating the table then it is column level constraint. For column level constraint a constraint name is not mandatory.

TABLE(ROW) LEVEL CONSTRAINT
If we provide constraint after providing all the columns then it is table level constraint.For table level constraint a constraint name is mandatory.

Advantage of table level constraint:
We can create composite PK and composite FK in table level constraints but we cant create these in column level constraints.

Example:
CREATE TABLE oracle_tab
(
ord_id  NUMBER,
pid NUMBER,
qty NUMBER(2),
ord_dt DATE NOT NULL, /*column level constraint(cant be created as table level constraint)*/
price NUMBER(9,1) DEFAULT 0, /*column level constraint(cant be created as table level constraint)*/
CONSTRAINT ord_pk PRIMARY KEY(ord_id,pid), /*table level(can be created either as table level constraint or column level)*/
CONSTRAINT ord_fk FOREIGN KEY(pid) REFERENCES products(pid),/*table level(can be created either as table level constraint or column level)*/
CONSTRAINT ord_ch CHECK(qty>0) /*table level(can be created either as table level constraint or column level)*/
);

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is sql low level language?

585


What is join view in sql?

522


i have 2 table table one 4 columns respective values a1 7,a2 6,a3 8 ,a4 12 & table two 4 colums respective values a1 7,a2 6,a3 8,a4 15.if table one & table two 3 colums same then 4th column values 1)Qes diff >5 then print 5 * diff value 2)Que diff <5 print 5

3218


What schema means?

533


What is compound trigger?

573






What is pl sql variable?

518


What do you mean by dbms? What are its different types?

559


Define sql delete statement.

576


What is the difference between sum and count in sql?

530


Explain the order of sql statement execution?

621


Enlist the characteristics of pl/sql?

1255


Mention what are the benefits of pl/sql packages?

544


How can we connect an Android App to an Oracle database and use the PL/SQL procedural code?

591


Why primary key is required?

571


Can we call procedure in select statement?

531