0% found this document useful (0 votes)
71 views47 pages

List of Practicals For (Ism) : Institute of Innovation in Technology & Management, New Delhi

The document provides details about SQL assignments for a database management course. It includes topics like what is SQL, features of SQL, data types in SQL, and instructions for creating tables, modifying table structures, and performing DML commands. The assignments involve creating tables for students and employees, inserting sample data, querying the tables to retrieve and filter records, updating records, renaming columns and tables, deleting records, and performing aggregate functions.

Uploaded by

Rohan Bagai
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
71 views47 pages

List of Practicals For (Ism) : Institute of Innovation in Technology & Management, New Delhi

The document provides details about SQL assignments for a database management course. It includes topics like what is SQL, features of SQL, data types in SQL, and instructions for creating tables, modifying table structures, and performing DML commands. The assignments involve creating tables for students and employees, inserting sample data, querying the tables to retrieve and filter records, updating records, renaming columns and tables, deleting records, and performing aggregate functions.

Uploaded by

Rohan Bagai
Copyright
© © All Rights Reserved
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
You are on page 1/ 47

RAHUL CHOPRA 40524488817

B.COM (E)
Institute of Innovation in Technology & Management, New Delhi

LIST OF PRACTICALS FOR (ISM)

Assignment No Topic Signature/Remarks

Assignment 1 What is SQL? Features of SQL


Data types in SQL
Create table student
Basics of SQL & DDL Modify the structure of student table
Commands Create table Employee
Modify the structure of Employee table
Assignment 2 Create table customer
Insert 5 rows each using all the three methods
Display the contents
Display CID and Fname
Display Fname,Lname and state
Display all records where state is Delhi
Display the states to which the customer
belongs
Select records of Delhi having name Rajiv
Display details of Customer with CID=98
Display details of Customer except CID=98
Retrieve all rows where CID is between 98
and 100
Display those rows where state name begins
DML Commands with ‘D’
Retrieve all rows where first name contains
the word’RAJ’
Retrieve all rows where name field contains
the word’RA ESH’
Retrieve all rows where city is Delhi,
Karnataka or Bangalore
Rename the table customer to cust
Delete all those rows of customers who stay
in Bangalore
Delete those customers who do not have Pin
Code
Rename column city to address
Delete the customers who do not belong to
Bangalore
Assignment 3 Create table employee

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)

List names of employees having salary


between 30,000 and 50,000
List name of employees who live in
Advanced DML Janakpuri
Commands List name of all female employees

List name of those employees whose bdate is


before 2 Nov. 1996
List all employees whose fname is “Ram”
and lName is “Kapoor”
Rename the column address to city
Sort the employees in descending order of
city
Update the person named “Ram” to “Vikas”
Update city of empid 101 to Jaipur
Delete record of empid 102
Display those employees whose salary is not
equal to 20,000
Assignment 4 Create table employee
Insert 5 records in employee table
Find average and total salaries of all
employees
Find average and total salaries of each
employee
Find minimum salary of Manager
Find the maximum salary of the Manager
How many employees are Managers
Count the total no. employees
Aggregate / Grouping Count the no. of departments available
Functions Count the no. of employees in each
department
Find the name of lowest paid employee for
each manager
Find the difference between highest and
lowest salaries for each dept
List average salary of each job excluding
managers
List total, Max, Min, Average salary of
employees job wise

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

retrieving data stored in a relational database.

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

SQL as their standard database language.

Also, they are using different dialects, such as −

 MS SQL Server using T-SQL,

 Oracle using PL/SQL,

 MS Access version of SQL is called JET SQL (native format) etc.

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.

There are various components included in this process.

These components are −

 Query Dispatcher

 Optimization Engines

 Classic Query Engine

 SQL Query Engine, etc.

A classic query engine handles all the non-SQL queries, but a SQL query engine won't handle logical

files.

Following is a simple diagram showing the SQL Architecture –

3
RAHUL CHOPRA 40524488817
B.C OM (E)

Features of SQL

SQL is widely popular because it has the following features −

 Allows users to access data in the relational database management systems.

 Allows users to describe the data.

 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.

 Allows users to create and drop databases and tables.

 Allows users to create view, stored procedure, functions in a database.

 Allows users to set permissions on tables, procedures and views.

 CHARACTER STRINGS DATA TYPES

Sr.No. DATA TYPE & Description

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.

UNICODE CHARACTER STRINGS DATA TYPES

Sr.No. DATA TYPE & Description

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 )

BINARY DATA TYPES

Sr.No. DATA TYPE & Description

1
Binary

5
RAHUL CHOPRA 40524488817
B.C OM (E)

Maximum length of 8,000 bytes(Fixed-length binary data )

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)

Create table student


Create table tablename(student_name char,roll-no,class));

7
RAHUL CHOPRA 40524488817
B.COM (E)

8
RAHUL CHOPRA 40524488817
B.COM (E)
Modify the structure of student table

Create table Employee

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

alter table table name drop(gender);

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

Display the contents


Select* from tablename.

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)

Delete the customers who do not belong to Bangalore


Delete from tablename where address!=’banglore’

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

Q. Find average and total salaries of all employees


=> select avg(salary), sum(salary) from employee

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. ;

Q. find minimum salary of manager


=> select min(salary) from employee where Job = ‘Manager’

37
RAHUL CHOPRA 40524488817
B.COM (E)
Q. Find the maximum salary of the manager
=> select max (salary) from employee where Job = ‘Manager’

Q. How many employees are managers


=> select count (*) from employee where Job = ‘Manager’

Change the column salary to hra

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)

Employee in each jobs.

42
RAHUL CHOPRA 40524488817
B.COM (E)
.

List total,max,min,avg,salary of each employees job wise

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)

Find the name of lowest paid employee each department


Select min(hra) from tablename group by dept_no

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

You might also like