The document provides SQL commands for Data Definition Language (DDL) and Data Manipulation Language (DML) operations. It includes commands to create, alter, and drop a student table, as well as to insert, view, update, and delete records. Various select queries demonstrate filtering and sorting data based on different conditions.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
9 views2 pages
Divisions of SQL
The document provides SQL commands for Data Definition Language (DDL) and Data Manipulation Language (DML) operations. It includes commands to create, alter, and drop a student table, as well as to insert, view, update, and delete records. Various select queries demonstrate filtering and sorting data based on different conditions.
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;