Primary Key & Foreign Key

Опубликовано: 30 Май 2026
на канале: CodeWithRahul
83
8

In this video, I have explained Primary Key and Foreign Key Constraint in detail.

Video Link -    • Primary Key & Foreign Key  

Click here to subscribe to my you tube channel-    / @codewithrahul1465  

#CodeWithRahul #SQL #Oracle #HappyLearning

If you learn something new from this video, please like this video and subscribe to my channel
CodeWithRahul


Primary Key/Foreign Key Commands for hands-on :

create table department_pk
(
dept_id INT PRIMARY KEY,
dept_name varchar2(50)
);

insert into department_pk values (1,'Admin');
insert into department_pk values (2,'IT');

select * from dba_constraints where lower(table_name)='department_pk';


create table employees_fk
(
emp_id INT PRIMARY KEY,
emp_name varchar2(50),
dept_id number,
foreign key(dept_id) references department_pk(dept_id)
);


insert into employees_fk values (1,'ABC',1);
insert into employees_fk values (2,'XYZ',3);


select * from dba_constraints where lower(table_name)='department_pk';
select * from user_constraints where lower(table_name)='employees_fk';