-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeys_L5.sql
More file actions
29 lines (23 loc) · 767 Bytes
/
Keys_L5.sql
File metadata and controls
29 lines (23 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use second;
# Primary key
drop table if exists akshay;
create table if not exists akshay(name varchar(50), usn int primary key );
select * from akshay;
# Composite key
#drop table if exists orders;
create table orders (order_id serial primary key , customer_id int,order_date date,primary key(order_id,cutomer_id));
select* from orders;
#foriegn key
drop table if exists orders;
create table if not exists orders (order_id serial primary key , cutomer_id int ,order_date date,foreign key(customer_id) references akshay(usn));
select * from orders;
#unique constraint
create table kumar(
em_id serial primary key,
email varchar(50) unique,
name varchar(50));
select * from kumar;
# check constraint
create table bhar(
age int check(age>18));
select * from bhar;