//create table student (sid,sname,sage,sdob)
create table studentsy
(
sid int,
sname varchar(20),
sage int,
sdob date
);
//describe student table
desc studentsy;
//insert 5 meaningful records
insert into studentsy
values(&id,'&name',&umar,'&janamdin');
//Display all details of student table
select * from studentsy;
HW Questions
1. Create table teacher(tid,tname,tage,dob)
2. Describe Teacher
3. Insert 5 records
4. Select the table teacher
==================================================
1. Select the table student
select * from studentsy;
2. Find the name of student whose sid is 4
select sname from studentsy where sid=4;
3.Find name and id of student whose age is above 20
select sname,sid from studentsy where sage>20;
Extra Question
Q. Delete all Records
delete from studentsy;
4. Delete any row
delete from studentsy where sname='Varun';
Extra
Delete records whose age is less than 18
delete from studentsy where sage<18;
Delete records whos name is varun
delete from studentsy where sname='Varun';
Delete records whose id is more than 1003 but less than 1005
delete from studentsy where sid>1003 and sid<1005;
Delete records whose id is more than 1003 but less than 1005 including boundaries
delete from studentsy where sid>=1003 and sid<=1005;
delete from studentsy where sid between 1003 and 1005;
Update Query
(Data Modification)
//change/update the dob of varun
update studentsy
set sdob='17-Feb-2005'
where sname='Varun';
//change name and age of id 1002
update studentsy
set sname='Shyama Chawla',sage=17
where sid=1002;
5.Change name of student whose age is 20
update studentsy
set sname='Varun Rohra'
where sage=20;
6. Change id of student whose sname is piyush
update studentsy
set sid=2004
where sname='piyush';
7. Truncate the table
truncate table studentsy;
8. Drop the table
drop table studentsy;