You are on page 1of 2

SQL COMMANDS

1. To create the table

create table employee(eid varchar(5), ename varchar(25),eaddress varchar(50),esal int,hra int)

2. To insert the record in the table

insert into employee values('E01','Deepa','H.No-123,Sec-12,Fbd',25000,2000)

insert more records as same

3. To create the table and set the primary key

create table employee(eid varchar(5) primary key, ename varchar(25),eaddress varchar(50),esal int,hra int)

insertion is same but duplicacy is not allowed

4. Deletion as per the query(requirement)

delete from employee where ename='Deepa'

delete from employee where esal=25000

delete from employee where esal<>25000

You can use any comparison operator (<,>,<=,>=,=,<>)

5. To change the structure of the table(modification in the structure)

alter table employee add contact varchar(10)

6. To update the record

update employee set contact='9876543210' where ename='Deepa'

7. To delete the structure of the table

drop table employee

8. Select queries as per the requirement

select * from employee

select eid,ename from employee

select eid,ename from employee where esal=25000

select * from employee where esal=25000

select * from employee where esal<35000

select hra,da from employee where esal<35000


select hra,da from employee where esal<=35000

select hra,da from employee where esal>35000

select hra,da from employee where esal>=35000

select hra,da from employee where esal<>35000

select * from employee where esal between 30000 and 35000

select * from employee where esal not between 30000 and 35000

select * from employee where eid='e01'

select * from employee where ename='deepa'

select * from employee where ename like 'd*'

select * from employee where ename like 'r*' and esal>=30000

select * from employee where ename like 'dee??'

select * from employee where ename not like 'dee??'

select * from employee where ename in('raj','rohit','deep')

SELECT * from employee where ename in('deepa','rohit')

SELECT eid,ename,esal,hra,da,bonus,esal+hra+da+bonus from employee

9. Group by Clause

SELECT ESAL FROM EMPLOYEE WHERE DEPT='FINANCE' GROUP BY ESAL

10. Normal queries for calculation

SELECT 45*7 AS RESULT

SELECT 45 / 5

All arithmetic calculations can be done easily by using the select command

You might also like