Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is integrity constraints?

Answers were Sorted based on User's Feedback



What is integrity constraints?..

Answer / s. syam sundar

which prevents the user from entering the duplicating into
tables or views is called integrity constraint
Ex: primary key constraint,foreign key constraint,unique
constraint,check constraint.

Is This Answer Correct ?    90 Yes 11 No

What is integrity constraints?..

Answer / aryarokz

Data integrity allows to define certain data quality
requirements that the data in the database needs to meet. If
a user tries to insert data that doesn't meet these
requirements, Oracle will not allow so.
Constraint types
There are five integrity constraints in Oracle.
Not Null
A column in a table can be specified not null. It's not
possible to insert a null in such a column. The default is
null. So, in the following create table statement, a null
can be inserted into the column named c.

create table ri_not_null (
a number not null,
b number null,
c number
);

insert into ri_not_null values ( 1, null, null);
insert into ri_not_null values ( 2, 3, 4);
insert into ri_not_null values (null, 5, 6);

The first to records can be inserted, the third cannot,
throwing a ORA-01400: cannot insert NULL into
("RENE"."RI_NOT_NULL"."A").
The not null/null constraint can be altered with

alter table ri_not_null modify a null;

After this modification, the column a can contain null values.
Unique Key
The unique constraint doesn't allow duplicate values in a
column. If the unique constraint encompasses two or more
columns, no two equal combinations are allowed.

create table ri_unique (
a number unique,
b number
);

However, if a column is not explicitely defined as not null,
nulls can be inserted multiple times:

insert into ri_unique values (4, 5);
insert into ri_unique values (2, 1);
insert into ri_unique values (9, 8);
insert into ri_unique values (6, 9);
insert into ri_unique values (null,9);
insert into ri_unique values (null,9);

Now: trying to insert the number 2 again into a:

insert into ri_unique values (2,7);

This statement issues a ORA-00001: unique constraint
(RENE.SYS_C001463 violated). Every constraint, by the way,
has a name. In this case, the name is: RENE.SYS_C001463.
In order to remove that constraint, an alter table ... drop
constraint ... is needed:

alter table ri_unique drop constraint sys_c001463;

Of course, it is also possible to add a unique constraint on
an existing table:

alter table ri_unique add constraint uq_ri_b unique (b);

A unique constraint can be extended over multiple columns:

create table ri_3 (
a number,
b number,
c number,
unique (a,b)
);

It is possible to name the constraint. The following example
creates a unique constraint on the columns a and b and names
the constraint uq_ri_3.

create table ri_3 (
a number,
b number,
c number,
constraint uq_ri_3 unique (a,b)
);

Primary Key
On a technical level, a primary key combines a unique and a
not null constraint. Additionally, a table can have at most
one primary key. After creating a primary key, it can be
referenced by a foreign key.

create table ri_primary_key (
a number primary key,
b number
);

Primary keys can explicitely be named. The following create
table statement creates a table with a primary key whose
name is pk_name.

create table ri_primary_key_1 (
a number,
b number,
c number,
constraint pk_name primary key (a, b)
);

Foreign Key
A foreign key constraint (also called referential integrity
constraint) on a column ensures that the value in that
column is found in the primary key of another table.
If a table has a foreign key that references a table, that
referenced table can be dropped with a drop table .. cascade
constraints.
It is not possible to establish a foreign key on a global
temporary table. If tried, Oracle issues a ORA-14455:
attempt to create referential integrity constraint on
temporary table.
Check
A check constraint allows to state a minimum requirement for
the value in a column. If more complicated requirements are
desired, an insert trigger must be used.
The following table allows only numbers that are between 0
and 100 in the column a;

create table ri_check_1 (
a number check (a between 0 and 100),
b number
);

Check constraints can be added after a table had been created:

alter table ri_check_1
add constraint ch_b check (b > 50);

It is also possible to state a check constraint that check
the value of more than one column. The following example
makes sure that the value of begin_ is smaller than the
value of end_.

create table ri_check_2 (
begin_ number,
end_ number,
value_ number,
check (begin_ < end_)
);

Is This Answer Correct ?    39 Yes 3 No

What is integrity constraints?..

Answer / guru

An integrity constraint is a declarative way to define a
business rule for a column of a table.

Is This Answer Correct ?    43 Yes 18 No

What is integrity constraints?..

Answer / sankar

The entity integrity constraint states that no primary key value can be null. This is because the primary key value is used to identify individual tuples in a relation . Having null value for the primary key implies that we cannot identify some tuples.This also specifies that there may not be any duplicate entries in primary key column key row.

Is This Answer Correct ?    6 Yes 0 No

What is integrity constraints?..

Answer / suresh kumar somayajula

Integrity constraint is a rue that restricts a column of a
table.

Is This Answer Correct ?    19 Yes 14 No

Post New Answer

More SQL PLSQL Interview Questions

Write a unique difference between a function and a stored procedure.

0 Answers  


Q1.all the depts which has more then 10 empls? Q2.all the dept which does not have any emply? Q3 all the emp which does not have any dept? Q4 get all the emply detais with the dept details it dept is exit otherwise any emp details? Q5 how to debugg the dynamic sql and packages?

2 Answers  


Is subquery faster than join?

0 Answers  


How to use boolean type in select statement?

0 Answers  


what are the different index configurations a table can have? : Sql dba

0 Answers  


What are synonyms in sql?

0 Answers  


package specification-3 procedures package body-4 procedures how can i write for other procedure in package body

2 Answers   Reliance,


How do I create a memory optimized filegroup?

0 Answers  


Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?

0 Answers  


select 1,col1,col2 from table1. output?

5 Answers   Ramco,


Is postgresql a nosql database?

0 Answers  


HP Interview -2016 Unix 1) grep command in unix 2) what is set command

1 Answers   HCL,


Categories