You are on page 1of 3

http://www.infotechcomputer.

in

“Jh x.ks'kk; ue%“

‘SQL’

What is SQL - Structured Query Language. it is a standard language which is used by various
DBMS packages with very small syntax changes. it is mainly used to query data from
database. or we can say to convert data into information.

SQL has varoius commands


Category of SQL Commands -
DDL - Data Defination Language (Create, Alter, Drop)
DML - Data Manipulation Language (Select , Insert , Update, Delete)
DCL - Data Control Language (Grant, Revoke)
TCL - Transaction Control Language (Commit, Savepoint, Rollback)'

1. Create - is used to create a table along with its structure


for eg.
create table student(roll int primary key, name char(20), class char(20))

2. Alter - is used to make changes in the structure (schema) of table. we can perform the
following things with alter command.
1. add new column (use add with alter command)
for eg.
alter table student add (city char(20))
2. modify data type of a column (use modify with alter command)
for eg.
alter table student modify city char(40)
3. remove a column (use drop with alter command)
for eg.
alter table student drop column city
4. change name of the column (use change with alter command)

INFOTECH Computer Education, Kishangarh (Raj)  9829171122 Page 1


http://www.infotechcomputer.in
for eg.
alter table student change city shahar char(20)

3. Drop - is used to remove the table


for eg.
drop table student

4. Select - is used to select (filter) data from the database (most useful and popular
command)
for eg.
1. select * from student - will display all the records from student table
2. select roll,name from student - will display only roll and name of student
3. select * from student where city='ajmer' - will display records of students living in ajmer
4. select * from student where marks between 20 and 60 - will display records of students
obtaining marks between 20 and 60
5. select * from student where class='XII' and sec='a' - will display records of student studying
in class XII and section A
6. select * from student where name like 'a%' - will display records of student whose name
starts with the letter a
7. select * from student where name like '____' - will display records of students whose name is
of four letters

5. Insert - is used to insert records in the table


for eg.
insert into student values(101,'ram','xi','c')

6. Update - is used to make changes in the data of table


for eg.
update student set city='pinkcity' where city='jaipur'

7. Delete - is used to delete records from the table


for eg.
delete from student where city='jaipur'

8. Grant - is used to assign various types of permission to users of the database.


for eg.
GRANT ALL ON student.* TO 'aman'@'localhost'

INFOTECH Computer Education, Kishangarh (Raj)  9829171122 Page 2


http://www.infotechcomputer.in

9. Revoke - is used to release the permission given to any user of the database.
for eg.
REVOKE INSERT ON student.* FROM 'aman'@'localhost'

10. Commit - is used to save the changes made in database permanently


for eg
commit

11. Savepoint - is used to create a checkpoint or savepoint at any point of the transaction.
for eg.
savpoint s1

12. Rollback - is used to undo the changes made in database.


a. partial rollback - rollback uptill a savepoint
b. complete rollback - rollback uptill the start of transaction
for eg.
1. rollback - will rollback the transaction completely
2. rollback to s1 - will rollback the transaction upto the specified savepoint

INFOTECH Computer Education, Kishangarh (Raj)  9829171122 Page 3

You might also like