ISM LAB PRACTICAL FILE (Harsh)
ISM LAB PRACTICAL FILE (Harsh)
ISM LAB PRACTICAL FILE (Harsh)
ON
ISM LAB
of
(2022)
SUBMITTED BY:
Harsh
01621001720
DR.
This is to certify that Practical file entitled, “ISM LAB” is bonafide work carried out by
Harsh student of BBA, Ideal Institute of Management and Technology (affiliated to GGSIP
University, Delhi) in partial fulfillment of the requirement for the award of degree of
Bachelor of Business Administration, under my guidance & Direction. To the best of my
knowledge and belief the data & information presented by her in the Practical has not been
submitted for the award of any other degree.
I am writing this practical file for the program of Bachelor of Business Administration on
“ISM LAB” for Ideal Institute of Management & Technology Affiliated to Guru Gobind
Singh Indraprastha University.
It has been a great challenge but a plenty of learning and opportunities to gain a huge amount
of knowledge on the way of writing this Practical file. I could not have completed my file
without the constant guidance of our Principle Dr. Seema Nath Jain, my faculty, who helped
me along the way and was always prepared to give me feedback and guidelines whenever I
needed it.
1. INTRODUCTION TO MY SQL 1.
SQL theory
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 −
-6-
PRACTICAL 1
DDL COMMANDS
(Data definition language)
a. DDL changes the structure of the table like creating a table, deleting a table, altering a
table, etc.
b. All the command of DDL are auto-committed that means it permanently save all the
changes in the database.
c. Some commands that come under DDL are:
CREATE
It is used to create a new table in the database.
ALTER
It is used to alter the structure of the database. This change could be either to
modify the characteristics of an existing attribute or probably to add a new
attribute.
DROP
It is used to delete both the structure and record stored in the table.
TRUNCATE
It is used to delete all the rows from the table and free the space containing the
table.
-7-
QUERY 1: Write a query to create table student.
To add columns to the table, we use alter command. Syntax of alter command is –
QUERY 3: Write a query to destroy the table and all the data held in it.
To destroy the table and all the data held in it, we use drop command. Syntax of drop
command is –
-8-
PRACTICAL 2
DML COMMANDS
(Data manipulation language)
a. DML commands are used to modify the database. It is responsible for all form of
changes in the database.
b. The command of DML is not auto-committed that means it can't permanently save all
the changes in the database. They can be rollback.
c. Some commands that come under DML are:
INSERT
It is used to insert data into the row of a table.
UPDATE
It is used to update or modify the value of a column in the table.
DELETE
It is used to remove one or more row from a table.
-9-
QUERY 4: Write a query to insert data in table student.
To insert data in table, we use insert command. Syntax of insert command is -
INSERT INTO tablename
(col1, col2, col3,.. . .col N)
VALUES (value1, value2, value3,.....valueN);
QUERY 5: Write a query to update and change the content of field name to DILAWAR
and subject to AKSHAY having roll no is 002.
QUERY 6: Write a query to delete from table where roll no is more than 003.
To delete from the table, we use delete command. Syntax of delete command is –
- 10
-
PRACTICAL 3:
DCL & DQL COMMANDS
(Data Control language & Data Query language)
a. DCL commands are used to grant and take back authority from any database user.
b. Here are some commands that come under DCL:
GRANT
It is used to give user access privileges to a database.
REVOKE
It is used to take back permissions from the user.
c. DQL is used to fetch the data from the database.
a. It uses only one command:
SELECT
It is the same as the projection operation of relational algebra. It is used to
select the attribute based on the condition described by WHERE clause.
- 11
-
QUERY 7:
To view all the data, we use select command. Syntax of view command is –
b) Write a query to view roll no and name from table student where subject
is commerce.
SELECT columnname
FROM tablename
WHERE conditions;
- 12 -
PRACTICAL 4
LOGICAL OPERATORS
AND Operator
It displays only those records where both the given conditions evaluates to True.
OR Operator
It displays the records where either one of the conditions evaluates to True.
NOT Operator
It can be used to put before any conditional statement to select rows for which that
statement is false.
- 13 -
QUERY 8: Write a query to retrieve the contents of the columns roll no, name, subject
from the table student where marks are between 90 and 100.
To retrieve the content of he columns roll no, name, subject from the table student where
marks are between 90 and 100, we use AND operator. Syntax of AND operator is –
Select column 1, column 2….
From tablename
Where condition 1 AND condition 2;
QUERY 9: Write a query to retrieve all fields of the table student where roll no has the
value 003 or 005.
To retrieve all fields of the table student where roll no has the value 003 or 005, we use OR
operator. Syntax of OR operator is –
Select * From tablename
Where condition 1 OR condition 2;
QUERY 10: Write a query to retrieve all fields of the table student who do not
have commerce or humanities as the subject.
To retrieve all fields of the table student who do no have commerce or humanities as the
subject, we use NOT operator. Syntax of NOT operator is –
Select * From tablename
Where NOT condition 1 OR condition 2;
- 14 -
PRACTICAL 5
RANGE SEARCHING OPERATORS
BETWEEN Operator
It allows you to select only rows that are within a specific range.
LIKE Predicate
It allows you to match on similar values rather than exact ones.
IN Predicate
It allows you to specify a list of values that you'd like to include in the results.
- 15 -
QUERY 11: Write a query to retrieve the contents of the columns roll no, name, subject
from the table student where marks are between 80 and 90 both inclusive.
To retrieve the contents of the columns roll no, name, subject from the table student where
marks are between 80 and 90 both inclusive, we use BETWEEN operator. Syntax of
BETWEEN operator is –
Select column 1, column 2….
From tablename
Where columnname BETWEEN value 1 AND value 2;
QUERY 12: Write a query to retrieve all information about students where the second
character of name is ‘a’.
To retrieve all information about students where the second character of name is „a‟, we use
like operator. Syntax of like operator is –
Select * from tablename
Where columnname LIKE condition
QUERY 13: Write a query to retrieve the contents of the columns roll no, name, subject
from the table student where name is either Harsh or Vansh or Gaurav.
To retrieve the contents of the columns roll no, name, subject from the table student where
name is either Harsh or Vansh or Gaurav, we use IN operator. Syntax of IN operator is -
Select columnname(s)
From tablename
Where columnname IN (value1, value2….);
- 16 -
PRACTICAL 6
ORDER BY CLAUSE
ORDER BY
It allows you to specify a list of values that you'd like to include in the results.
- 17 -
QUERY 14: Write a query to retrieve all rows from student and display this data sorted
on the value contained in the field roll no in:
a) Ascending order
To retrieve all rows from student and display this data sorted on the value contained in the
field roll no in ascending order, we use order by clause. Syntax of order by clause is -
b) Descending order
To retrieve all rows from student and display this data sorted on the value contained in the
field roll no in descending order, we use order by clause. Syntax of order by clause is -
- 18 -
PRACTICAL 7
AGGREGATE FUNCTIONS
Average: AVG
It returns the average of the values in a specified column.
Minimum: MIN
It returns the smallest value in the specified table field.
Maximum: MAX
It returns the largest value from the specified table field.
Total: SUM
It returns the sum of all the values in the specified column.
Count: COUNT
It returns the total number of values in the specified field.
- 19 -
QUERY 15: Write a query to find the average of the marks column.
To find the average marks, we use average function. Syntax of average function is –
QUERY 16: Write a query to find the sum of the marks column.
QUERY 17: Write a query to count the number of students with marks more than 85.
To find the number of students with marks more than 85, we use count function. Syntax of
count function is –
Select COUNT
from tablename
where condition;
- 20 -
QUERY 18: Write a query to retrieve the information of student having:
a) Maximum marks
b) Minimum marks
To retrieve the information of student having maximum marks, we use MIN function.
Syntax of MIN function is –
- 21 -