List of Practicals For (Ism) : Institute of Innovation in Technology & Management, New Delhi
List of Practicals For (Ism) : Institute of Innovation in Technology & Management, New Delhi
B.COM (E)
Institute of Innovation in Technology & Management, New Delhi
Insert 5 records
List name of all employees who work in Dept
No. 5
Find names and salary of all the employees
sorted according to salary
1
RAHUL CHOPRA 40524488817
B.COM (E)
2
RAHUL CHOPRA 40524488817
B.C OM (E)
ASSIGNMENT -1
What is SQL?
SQL is Structured Query Language, which is a computer language for storing, manipulating and
SQL is the standard language for Relational Database System. All the Relational Database Management
Systems (RDMS) like MySQL, MS Access, Oracle, Sybase, Informix, Postgres and SQL Server use
When you are executing an SQL command for any RDBMS, the system determines the best way to
carry out your request and SQL engine figures out how to interpret the task.
Query Dispatcher
Optimization Engines
A classic query engine handles all the non-SQL queries, but a SQL query engine won't handle logical
files.
3
RAHUL CHOPRA 40524488817
B.C OM (E)
Features of SQL
Allows users to define the data in a database and manipulate that data.
Allows to embed within other languages using SQL modules, libraries & pre-compilers.
1 Char
Maximum length of 8,000 characters.( Fixed length non-Unicode characters)
4
RAHUL CHOPRA 40524488817
B.COM (E)
Varchar
2
Maximum of 8,000 characters.(Variable-length non-Unicode data).
varchar(max)
3 Maximum length of 2E + 31 characters, Variable-length non-Unicode data (SQL Server 2005
only).
Text
4
Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters.
1 Nchar
Maximum length of 4,000 characters.( Fixed length Unicode)
Nvarchar
2
Maximum length of 4,000 characters.(Variable length Unicode)
nvarchar(max)
3
Maximum length of 2E + 31 characters (SQL Server 2005 only).( Variable length Unicode)
Ntext
4
Maximum length of 1,073,741,823 characters. ( Variable length Unicode )
1
Binary
5
RAHUL CHOPRA 40524488817
B.C OM (E)
Varbinary
2
Maximum length of 8,000 bytes.(Variable length binary data)
varbinary(max)
3
Maximum length of 2E + 31 bytes (SQL Server 2005 only). ( Variable length Binary data)
Image
4
Maximum length of 2,147,483,647 bytes. ( Variable length Binary Data)
1. Create table student having fields student names, roll no. , class,
Course,
2. Create table employee having fields, employee, Id Name,
Department, Salary, Date of Joining.
6
RAHUL CHOPRA 40524488817
B.COM (E)
7
RAHUL CHOPRA 40524488817
B.COM (E)
8
RAHUL CHOPRA 40524488817
B.COM (E)
Modify the structure of student table
9
RAHUL CHOPRA 40524488817
B.COM (E)
10
RAHUL CHOPRA 40524488817
B.COM (E)
Alter table
Alter table tablename add(gander char);
11
RAHUL CHOPRA 40524488817
B.COM (E)
12
RAHUL CHOPRA 40524488817
B.COM (E)
Droping
13
RAHUL CHOPRA 40524488817
B.COM (E)
14
RAHUL CHOPRA 40524488817
B.COM (E)
Insert of rows and column
15
RAHUL CHOPRA 40524488817
B.COM (E)
ASSIGNMENT-2
16
RAHUL CHOPRA 40524488817
B.COM (E)
Delete the customers who do not belong to Bangalore
Delete from tablename where state=’banglore’
17
RAHUL CHOPRA 40524488817
B.COM (E)
Rename column city to address
Alter table tablename rename column state to address
RAHUL CHOPRA 40524488817
B.COM (E)
21
RAHUL CHOPRA 40524488817
B.COM (E)
22
RAHUL CHOPRA 40524488817
B.COM (E)
Assignment -3
Describe employee record.
Desc tablename
23
RAHUL CHOPRA 40524488817
B.COM (E)
Insert 5 records
Insert into tablename values(105,’kate,’xander,7-apr-1995,’banglore’,’female’,500000,15)
RAHUL CHOPRA 40524488817
B.COM (E)
List name of all employees who work in Dept No. 5
Select fname,lname from tablename where deptno=5
Find names and salary of all the employees sorted according to salary
Asc
25
RAHUL CHOPRA 40524488817
B.COM (E)
Desc
26
RAHUL CHOPRA 40524488817
B.COM (E)
27
RAHUL CHOPRA 40524488817
B.COM (E)
List name of all female employees
Select fname,lname from tablename where gender=’female’
28
RAHUL CHOPRA 40524488817
B.COM (E)
Update the person named “Raj” to “ramesh”
Update table name set fname=’raj’ where fname=’ramesh’;
29
RAHUL CHOPRA 40524488817
B.COM (E)
Update city of empid 101 to Jaipur
Update tablename set address=’jaipu’ where empid=101;
30
RAHUL CHOPRA 40524488817
B.COM (E)
31
RAHUL CHOPRA 40524488817
B.COM (E)
Delete record of empid 102
32
RAHUL CHOPRA 40524488817
B.COM (E)
List names of employees having salary between 30,000 and 50,000
Select* from tablename where salary!=25000;
33
RAHUL CHOPRA 40524488817
B.COM (E)
ASSIGNMENT-4
Q. Create table employee with the following attribute emp no , emp name, salary, commission,
job, dept no.
34
RAHUL CHOPRA 40524488817
B.COM (E)
Q. Insert 5 rows in the table
Insert into tablename values ( ..................................... );
Q. Desc, Select
35
RAHUL CHOPRA 40524488817
B.COM (E)
Q. Desc, Select
36
RAHUL CHOPRA 40524488817
B.COM (E)
Q. Find average and total salaries of each employess
=> select avg(salary), sum(salay) from employee group by Dept no. ;
37
RAHUL CHOPRA 40524488817
B.COM (E)
Q. Find the maximum salary of the manager
=> select max (salary) from employee where Job = ‘Manager’
38
RAHUL CHOPRA 40524488817
B.COM (E)
result
39
RAHUL CHOPRA 40524488817
B.COM (E)
List job of all the employees where min salary is more than 4
40
RAHUL CHOPRA 40524488817
B.COM (E)
List jobs and number of jobs In marketing
41
RAHUL CHOPRA 40524488817
B.COM (E)
42
RAHUL CHOPRA 40524488817
B.COM (E)
.
43
RAHUL CHOPRA 40524488817
B.COM (E)
Count no. of department available
Select count (distinct(dept_no)) from tablename.
44
RAHUL CHOPRA 40524488817
B.COM (E)
Count the no. of employee in each department
Select cunt(*) from tablename group by DEPT_NO
45
RAHUL CHOPRA 40524488817
B.COM (E)
46
RAHUL CHOPRA 40524488817
B.COM (E)
Find the difference between the higest and the lowest salaries for each department
Select max(hra)-min(hra) as difference from tablename group by dept_no
47
RAHUL CHOPRA 40524488817
B.COM (E)
List avg salary for all the dept from where department having more than two salaries
Select avg(hra) from tablename having count(dept_no)>=2
48
RAHUL CHOPRA 40524488817
B.COM (E)
Count the number of employees
Select count(*)from tablename
49