DDL (Data definition language)
'''Create the table'''
create database sultan;
create table student(regno int,sname varchar(20),gender char,mark int,address
varchar(20));
'''Alter the table'''
alter table student add City char(20);
alter table student alter column City varchar(20);
alter table student drop column City;
'''Drop the table'''
drop table student;
DML (Data manipulation language)
'''Insert values in table'''
insert into student values(1,'Shahidha','F',456,'Chennai');
insert into student(regno,sname,gender,address) values
(2,'Sultan','M','Chennai');
'''View the table'''
select * from student;
select * from student where mark>=400;
select * from student where gender='f';
select regno,gender,address from student where mark>=400;
select sname as 'Student name',address as 'Location' from student;
select sname +' lives in '+address from student;
select top 5 * from student;
select top 5 percent * from student;
select * from student orderby Regno;
select * from student orderby Regno Asce;
select * from student orderby Regno Desc;
select * from student where address='Chennai' or address='ramapuram';
select regno,sname,mark from student where mark>=400 or gender='f';
select * from student where address='Chennai' and gender='f';
select regno,sname,mark from student where mark between 300 and 400;
select regno,sname,address from student where mark is null;
select regno,sname,address from student where mark is not null;
select * from student where address in('Chennai','usa');
select * from student where address not in('Chennai','usa');
select * from student where sname like 'A%';
select * from student where sname like 'A%S';
select * from student where sname like 'Bal_';
select * from student where sname like 'A[NRK]%';
select * from student where sname like 'A[B-K]%';
'''Update the table'''
update student set City='Chennai' where Regno=7;
update student set City='Salem';
'''Delete values in the values'''
delete from student where Regno=1;
delete from student;
'''Drop the table'''
drop table student;