-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathSQL DML.txt
34 lines (33 loc) · 1.61 KB
/
SQL DML.txt
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
30
31
32
33
34
show databases;
create database student;
use student;
create table stud_tab(stud_id int(4),stud_name varchar(20),stud_dept varchar(10),stud_dob date,stud_address varchar(10));
desc stud_tab;
insert into stud_tab values(1,'Ram','Comp','2002-11-05','Pune');
insert into stud_tab values(2,'Soham','IT','2002-09-03','Nashik');
insert into stud_tab values(3,'Ramesh','Comp','2002-03-19','Pune');
insert into stud_tab values(4,'Mohan','AI&DS','2002-02-22','Nagpur');
select * from stud_tab;
alter table stud_tab add shift varchar(10);
update stud_tab set shift='first' where stud_id=1;
update stud_tab set shift='second' where stud_id=2;
update stud_tab set shift='first' where stud_id=3;
update stud_tab set shift='first' where stud_id=4;
select * from stud_tab;
insert into stud_tab values(5,'Omkar','ENTC','2002-06-26','Pune','second');
select * from stud_tab;
delete from stud_tab where stud_address='Nagpur';
select * from stud_tab;
update stud_tab set stud_id=4 where stud_name='Omkar';
select * from stud_tab;
select * from stud_tab where stud_dob between '2002-01-01' and '2002-07-01';
alter table stud_tab add stud_fees int(15);
update stud_tab set stud_fees=15000 where stud_id=1;
update stud_tab set stud_fees=20000 where stud_id=2;
update stud_tab set stud_fees=20000 where stud_id=3;
update stud_tab set stud_fees=15000 where stud_id=4;
select * from stud_tab;
select * from stud_tab where stud_fees=(select max(stud_fees) from stud_tab);
select sum(stud_fees) from stud_tab;
create table stud_info as select stud_id,stud_name from stud_tab;
select stud_id from stud_tab union select stud_id from stud_info;