Login using Social Account
     Continue with GoogleLogin using your credentials
Primary Key and Unique Key
Primary Key vs Unique Key
Auto Generation of Primary/Unique Keys
SELECT LAST_INSERT_ID();Let's see all above in action. With AUTO_INCREMENT and Primary key
%%sql
use retail_db;
drop table if exists emp_<<your lab username>>;
drop table if exists deptt_<<your lab username>>;
create table deptt_<<your lab username>> (
depid int not null auto_increment,
depname varchar(100) not null,
depcity varchar(100) not null,
depstreet varchar(100) not null,
depopendate date,
primary key ( depid )
);
Without AUTO_INCREMENT and with Primary key
%%sql
use retail_db;
drop table if exists emp_<<your lab username>>;
drop table if exists deptt_<<your lab username>>;
create table deptt_<<your lab username>> (
depid int not null,
depname varchar(100) not null,
depcity varchar(100) not null,
depstreet varchar(100) not null,
depopendate date,
primary key ( depid )
);
Without AUTO_INCREMENT and with the Primary key added later
%%sql
use retail_db;
drop table if exists emp_<<your lab username>>;
drop table if exists deptt_<<your lab username>>;
create table deptt_<<your lab username>> (
depid int not null,
depname varchar(100) not null,
depcity varchar(100) not null,
depstreet varchar(100) not null,
depopendate date
);
alter table deptt_<<your lab username>> add primary key (depid);
alter table deptt_<<your lab username>> drop primary key;
alter table deptt_<<your lab username>> add primary key pk_deptt (depid);
alter table deptt_<<your lab username>> drop primary key;
describe deptt_<<your lab username>>;
OR
show create table deptt_<<your lab username>>;
Taking you to the next exercise in seconds...
No hints are availble for this assesment
Answer is not availble for this assesment
Loading comments...