Skip to content

Commit 9319cce

Browse files
author
Shahbaz Khan
committed
adding constraints.sql
1 parent bdd3feb commit 9319cce

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Constraints.sql

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--1.Unique:It ensures that an attribute can't caontain duplicate values
2+
--2.Not Null: Particular attribute can't be left without value
3+
/*3.Primary Key: It is both unique as well as not null
4+
4.Check: Checks and ensures that input in specific attribute is
5+
within the domain conditions or constraints specified in
6+
check
7+
Example- check(age>10) will ensure that age attribute can
8+
values more than 10 only.
9+
5. Foreign Key: When primary key of one table is used as a refrence
10+
in another table
11+
12+
A. Including a foreign key while creating the table */
13+
create table course(
14+
cid varchar2(10),
15+
cname varchar2(20),
16+
eid int refrences empl1(roll_no)
17+
)
18+
--B.Including a foreign key in already created table
19+
alter table course add constraint fk
20+
foreign key(eid) refrences empl1(roll_no)
21+
22+
/*6.Default: It provides default inputs for an attribute if no
23+
data is given for that particular attribute
24+
25+
Example:
26+
salary int dafault 10000

0 commit comments

Comments
 (0)