You are on page 1of 51

GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY

INSTITUTE OF INNOVATION IN TECHNOLOGY AND MANAGEMENT

SUBJECT NAME : INFORMATION SYSTEMS MANAGEMENT


PRACTICAL FILE
SUBJECT CODE : BBA-307

Submitted To : Submitted By:


Ms.Harsh Arora Name: PRACHI MEHTA
( Assistant Professor) Class: BBA (E1) V
Enrolment No.: 03124401721
CONTENTS

S.NO. TITLE PAGE NO.

1. INTRODUCTION TO SQL 3-6

2. ASSIGNMENT-1 7-9
CLASS TABLE

3. ASSIGNMENT-2 10-24
CUSTOMER TABLE

4. ASSIGNMENT-3 25-36
EMPLOYEE TABLE

5. ASSIGNMENT-4 37-49
EMPLOYEE123

2
SQL

Structured query language (SQL) is a programming language for storing and processing
information in a relational database. A relational database stores information in tabular form,
with rows and columns representing different data attributes and the various relationships
between the data values.

HISTORY
SQL has been around since the 1970s, and was standardized by the American National
Standards Institute (ANSI) in 1986. Since then, SQL has become the most widely used
language for managing relational databases and has undergone several revisions to keep pace
with the evolving needs of the database industry.

FEATURES
1. Data Definition Language (DDL): SQL provides a set of commands to define and modify
the structure of a database, including creating tables, modifying table structure, and
dropping tables.
2. Data Manipulation Language (DML): SQL provides a set of commands to manipulate
data within a database, including adding, modifying, and deleting data.
3. Query Language: SQL provides a rich set of commands for querying a database to
retrieve data, including the ability to filter, sort, group, and join data from multiple tables.
4. Transaction Control: SQL supports transaction processing, which allows users to group a
set of database operations into a single transaction that can be rolled back in case of
failure.
5. Data Integrity: SQL includes features to enforce data integrity, such as the ability to
specify constraints on the values that can be inserted or updated in a table, and to enforce
referential integrity between tables.
6. User Access Control: SQL provides mechanisms to control user access to a database,
including the ability to grant and revoke privileges to perform certain operations on the
database.
7. Portability: SQL is a standardized language, meaning that SQL code written for one
database management system can be used on another system with minimal modification.

3
SQL COMMANDS
Structured query language (SQL) commands are specific keywords or SQL statements that
developers use to
manipulate the data stored in a relational database. You can categorize SQL commands as
follows:
Data Definition Language
Data definition language (DDL) refers to SQL commands that design the database structure.
Database
engineers use DDL to create and modify database objects based on the business requirements.
For example,
the database engineer uses the CREATE command to create database objects such as tables,
views, and
indexes.
Data Query Language
Data query language (DQL) consists of instructions for retrieving data stored in relational
databases. Software
applications use the SELECT command to filter and return specific results from a SQL table.
Data Manipulation Language
Data manipulation language (DML) statements write new information or modify existing
records in a
relational database. For example, an application uses the INSERT command to store a new
record in the
database.
Data Control Language
Database administrators use data control language (DCL) to manage or authorize database
access for other
users. For example, they can use the GRANT command to permit certain applications to
manipulate one or
more tables.
Transaction Control Language
The relational engine uses transaction control language (TCL) to automatically make
database changes. For

4
example, the database uses the ROLLBACK command to undo an erroneous transaction.

DATA TYPES
Data types are used to represent the nature of the data that can be stored in the database table.
For
example, in a particular column of a table, if we want to store a string type of data then we
will
have to declare a string data type of this column.
Data types mainly classified into three categories for every database.
o String Data types
o Numeric Data types
o Date and time Data types
A list of data types used in SQL database:
1. Integer
Integer data types often represent whole numbers in programming. An integer value moves
from one integer to another without acknowledging fractional numbers in between. The
number of digits can vary based on the device, and some programming languages may allow
negative values.
2. Character
In coding, alphabet letters denote characters. Programmers might represent these data types
as (CHAR) or (VARCHAR), and they can be single characters or a string of letters.
Characters are usually fixed-length figures that default to 1 octet—an 8-bit unit of digital
information—but can increase to 65,000 octets.
3. Date
This data type stores a calendar date with other programming information. Dates are typically
a combination of integers or numerical figures. Since these are typically integer values, some
programs can store basic mathematical operations like days elapsed since certain events or
days away from an upcoming event.
4. Floating point (real)
Floating-point data types represent fractional numbers in programming. There are two main
floating-point data types, which vary depending on the number of allowable values in the
string:
Float: A data type that typically allows up to seven points after a decimal.
Double: A data type that allows up to 15 points after a decimal.

5
5. Long
Long data types are often 32- or 64-bit integers in code. Sometimes, these can represent
integers with 20 digits in either direction, positive or negative. Programmers use an
ampersand to indicate the data type is a long variable.
6. Short
Similar to the long data type, a short is a variable integer. Programmers represent these as
whole numbers, and they can be positive or negative. Sometimes a short data type is a single
integer.
7. String
A string data type is a combination of characters that can be either constant or variable. This
often incorporates a sequence of character data types that result in specific commands
depending on the programming language. Strings can include both upper and lowercase
letters, numbers and punctuation.
8. Boolean
Boolean data is what programmers use to show logic in code. Its typically one of two
values—true or false—intended to clarify conditional statements. These can be responses to
if/when scenarios, where code indicates if a user performs a certain action. When this
happens, the Boolean data directs the program response, which determines the next code in
the sequence.
9. Nothing
The nothing data type shows that a code has no value. This might indicate that a code is
missing, the programmer started the code incorrectly or that there were values that defy the
intended logic. Its also called the nullable type.
10. Void
Similar to the nothing type, the void type contains a value that the code cannot process. Void
data types tell a user that the code can return a response. Programmers might use or encounter
the void data type in early system testing when there are no responses programmed yet for
future steps.

6
ASSIGNMENT-1

CREATE TABLE STUDENT


create table studentm2(rollno number(10),name varchar(20),address varchar(20));

desc studentm2;

7
CREATING NEW COLUMN
alter table studentm2 add contactnumber number(10);

desc studentm2;

8
INSERT VALUES
insert into studentm2 values(084,’Jasleen’,’Hari Nagar’,8552367845);

select*from studentm2

9
ASSIGNMENT-2

CREATE TABLE CUSTOMER


Create table customer(customerid number(10),customerfname varchar(20),customerlname
varchar(20),customerstate varchar(10),customerpincode number(10));

10
INSERT CUSTOMER VALUES
insert into customer values(101,’Dev’,’Verma’,’Delhi’,110027);

11
12
EXTRACT TABLE RECORDS
Select*from customer

DISPLAY CUSTOMER ID AND FNAME


Select customerid,customerfname from customer;

13
DISPLAY FNAME,LNAME AND STATE
Select customerfname,customerlname,customerstate from customer;

DISPLAY ALL RECORDS WHERE STATE IS DELHI


Select* from customer where customerstate=’Delhi’

14
DISPLAY FNAME,LNAME CONCATED WITH STATE
Select concat(customerfname,customerlname),customerstate from customer;

DISPLAY THE RECORDS WHERE PIN IS NOT ENTERED


Select* from customer where customerpincode is null;

15
SELECT CUSTOMERSTATE FROM CUSTOMER
Select customerstate from customer;

SELECT RECORDS OF DELHI HAVING NAME RAJ


Select customerstate,customerfname,customerlname,customerid,customerpincode from
customer where customerfname=’Raj’

16
DISPLAY RECORDS OF DELHI OR PUNJAB
Select*from customer where customerstate=’Delhi’ or customerstate=’Punjab’

DISPLAY DETAILS OF CUSTOMER WHERE CUSTOMERID IS 104


Select*from customer where customerid=104

17
DISPLAY DETAILS OF CUSTOMER EXCEPT CUSTOMERID 104
Select*from customer where customerid!=104

USE ALIAS NAME TO DISPLAY CUSTOMERID


Select customerid as CID from customer;

18
RETRIEVE ALL ROWS WHERE CID IS BETWEEN 102 AND 104
Select*from customer where customerid between 102 and 104;

DISPLAY THOSE ROWS WHERE STATE NAME BEGINS WITH ‘D’


Select*from customer where customerstate like ’D%’

19
RETRIEVE ALL ROWS WHERE FIRST NAME CONTAINS THE WORD ‘RAJ’
Select*from customer where customerfname like ’%Raj’;

RETRIEVE ALL ROWS WHERE NAME FIELD CONTAINS THE WORD


‘HIMANSHI’
Select*from customer where customerfname like’%Himanshi’;

20
RETRIEVE ALL ROWS WHERE STATE IS DELHI OR PUNJAB
Select*from customer where customerstate=’Delhi’ or customerstate=’Punjab’;

RENAME THE TABLE CUSTOMER TO CUST


rename customer to cust;

21
DELETE ALL THOSE ROWS OF CUSTOMERS WHO STAY IN KERALA
delete from cust where customerstate ‘Kerala’;

Select*from cust

22
DELETE THOSE CUSTOMERS WHO DO NOT HAVE PINCODE
delete from cust where customerpincode is null;

select*from cust

23
RENAME COLUMN STATE TO ADDRESS
alter table cust rename column customerstate to customeraddress

select*from cust;

24
DELETE THE CUSTOMERS WHO DO NOT BELONG TO DELHI
delete from cust where customeraddress not in(‘Delhi’)

select*from cust;

25
ASSIGNMENT-3

CREATE TABLE EMPLOYEE


create table employee1(empid number(10),empfname varchar(20),emplname
varchar(20),empgender varchar(10),empaddress varchar(20),empsalary
number(20),empdepartment number(10),empdob date);

26
INSERT EMPLOYEE VALUES INTO EMPLOYEE TABLE
insert into employee1 values(1,’Ayush’,’Male’,’Dwarka’,1000000,1,’27-April-1999’)

27
EXTRACT THE TABLE RECORDS
Select*from employee1

28
DISPLAY EMPFNAME EMPLOYEE DEPARTMENT IS ‘5’
Select empfname from employee1 where empdepartment=5

DISPLAY EMPFNAME,EMPLNAME,EMPSALARY FROM EMPLOYEE TABLE IN


ORDER OF EMPSALARY DESCRIPTION
Select empfname,emplname,empsalary from employee1 order by empsalary desc;

29
SELECT EMPFNAME AND EMPLNAME WHERE EMPSALARY IS BETWEEN
30000 AND 50000
Select empfname,emplname,empsalary from employee1 where empsalary between 30000 and
50000

DISPLAY EMPFNAME AND EMPLNAME WHERE EMPADDRESS IS ‘DWARKA’


Select empfname,emplname from employee1 where empaddress = ‘Dwarka’;

30
DISPLAY EMPFNAME AND EMPLNAME WHERE EMPGENDER IS ‘FEMALE’
Select empfname,emplname from employee1 where empgender=’Female’

DISPLAY EMPFNAME AND EMPLNAME WHERE EMPDOB IS


‘2-NOVEMBER-1996’
Select empfname,emplname from employee1 where empdob=’2-November-1996’;

31
DISPLAY EMPFNAME AND EMPLNAME WHERE EMPFNAME=AMIT’ AND
EMPLNAME=KUMAR’
select empfname,emplname from employee1 where empfname=’Amit’ and
emplname=’Kumar’

RENAME COLUMN EMPADDRESS TO EMPCITY


alter table employee1 rename column empaddress to empcity;

32
select*from employee1

DISPLAY EMPFNAME AND EMPLNAME IN ORDER OF EMPLOYEE CITY


DESCRIPTION
select empfname,emplname from employee1 order by empcity desc;

33
UPDATE EMPFNAME TO ANKITA WHERE EMPFNAME IS ISHITA
update employee1 set empfname=’Ankita’ where empfname=’Ishita’

select* from employee1

34
UPDATE EMPCITY TO JAIPUR WHERE EMPID IS 1
update employee1 set empcity=’Jaipur’ where empid=1;

select*from employee1

35
DELETE EMPLOYEE RECORD WHERE EMPID IS 2
delete from employee1 where empid=2;

36
DISPLAY EMPFNAME AND EMPLNAME WHERE EMPSALARY IS 30000
select empfname,emplname from employee where empsalary!=30000;

37
ASSIGNMENT-4

CREATE TABLE EMPLOYEE


create table employee123(empid number(10),empfname varchar(10),emplname
varchar(10),empdepartment number(10),empdesignation varchar(10),empsalary number(10);

38
INSERT VALUES
insert into employee123 values(1,’Ayush’,’Dawar’,101,’Manager’,100000);

39
EXTRACT TABLE RECORDS
select*from employee123

40
DISPLAY AVERAGE EMPSALARY
select avg(empsalary) from employee123

DISPLAY SUM OF EMPSALARY


select sum(empsalary) from employee123

41
DISPLAY MINIMUM OF EMPSALARY
select min(empsalary) from employee123

DISPLAY MAXIMUM OF EMPSALARY


select max(empsalary) from employee123

42
DISPLAY MAX OF EMPSALARY FROM THE DESIGNATION OF MANAGER
select max(empsalary) from employee123 where empdesignation=’Manager’

DISPLAY COUNT OF EMPDESIGNATION WHERE EMPDESIGNATION IS


MANAGER
select count(empdesignation) from employee123 where empdesignation=’Manager’

43
select empsalary+empsalary*50/100 from employee123

select empsalary+empsalary*50/100 HRA from employee123

44
DISPLAY COUNT OF EMPID
select count(empid) from employee123

DISPLAY COUNT OF EMPDEPARTMENT


select count(empdepartment) from employee123

45
DISPLAY COUNT OF EMPLDEPARTMENT WHERE EMPDEPARTMENT IS 101
select count(empdepartment) from employee123 where empdepartment=’101’

select empsalary*10/100 from employee123 where empsalary>50000

46
select empfname,emplname,empsalary,empid,empdesignation from employee123 where
empsalary in(select min (empsalary) from employee123 where empdesignation=’Manager’)

select empsalary*15/100 from employee123 where empdepartment=110

47
select count(empid),avg(empsalary) from employee123 group by empdepartment having
count(empid)>0

select empdesignation from employee123 where empsalary>4000

48
select empdesignation,count(empdesignation) from employee123 group by empdesignation

select avg(empsalary) from employee123 where empdesignation=’Manager’

49
select sum(empsalary),max(empsalary),min(empsalary),avg(empsalary) from employee123
where empdesignation =’Assistant’

50
51

You might also like