Day 3 - SQL Commands - Youtube
Day 3 - SQL Commands - Youtube
Primary Key is used to recognize each record in a distinct manner, it will not
accept nulls and there can be only one Primary Key in a table.
Primary Key could be on multiple columns - Composite Primary Key.
___________________________________________________________________________________
____________________________
desc email_registration;
Create a Department table with the names of all the departments in the company -
create table department(
dept_name varchar(30) primary key,
dept_head varchar(30)
);
Now try inserting a record with a deparment name that is not in the department
table -
insert into employee (f_nm,l_nm,age,dept) values
('priya','darshini',30,'HealthCare');
Suppose, there is no data in employee table with that department, then what would
happen -
delete from employee where dept = 'HR';
Now, the (delete from department where dept_name = "HR";) statement will work.
___________________________________________________________________________________
__________________________