ISM Lab File

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 35

ASSIGNMENT 1

Q.1. Create a table named Student_Moksh using PRIMARY KEY.


CREATE TABLE - It allows the user to create and define a table.
SYNTAX:
CREATE TABLE schema_name.table_name
(column_1 data_type column_constraint, column_2 data_type
column_constraint…table constraint);

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.2. Insert 10 rows using INSERT INTO command in Student_Moksh.
INSERT- It is used to insert a single record or multiple records into a table.
SYNTAX:
INSERT INTO table (column1,column 2,…,column_n) Values
(expression1,expression2,…expression_n);

DESCRIBE – It lists the column definitions for the specified table, view or synonym,
or the specifications for the specified function or procedure.
SYNTAX:
DESC table
DESC view
DESC synonym
DESC package
DESC function

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
ASSIGNMENT 2

SELECT – It is used to retrieve records from one or more tables in an Oracle


Database.
SYNTAX:
SELECT expressions FROM tables
[WHERE conditions];
Q.1. Select all records from Employee_MokshEmp

Q.2. Select all records whose Department is ‘Marketing’.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.3. Select all records whose Department is ‘Sales’.

Q.4. Select all records whose Department is ‘Administration’.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.5. Select all records whose Department is ‘IT’.

Q.6. Select all records whose Designation is ‘Clerk’.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.7. Select all records whose Salary is greater than 50000.

Q.8. Select all records whose Salary is less than 30000.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
ASSIGNMENT 3

Q.1. Select the NAME column using ORDER BY command from Student_Moksh.

ORDER BY CLAUSE – It is used to sort the records in the result set. It can only be
used in SELECT statements.
SYNTAX:
SELECT expressions
FROM tables
[WHERE conditions]
ORDER BY expression [ASC|DESC];

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.2. Arrange the NAME column in descending order using ORDER BY command in
Student_Moksh.

PATTERN MATCHING – It is used to compare character data.


Q.3. List names which have ‘a’ as their second character.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.4. List names beginning from ‘iv’ and is 4 characters long.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
ASSIGNMENT 4

Q.1. Change the city of Shreya from Delhi to Mumbai in Student_Moksh using
UPDATE command.
UPDATE – It is used to update existing records in a table in an Oracle Database.
SYNTAX:
UPDATE table
SET column1 = expression1,
Column 2 = expression2,
Column 3 = expression3,
[WHERE conditions];

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Using the SELECT statement, we can view the changes.

Q.2. Update and increase the FEES by 3000 in Student_MokshArya.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Here we can see the updated table.

Q.3. Select all the different cities in Student_Moksh

DISTINCT CLAUSE - The DISTINCT CLAUSE is used to remove duplicates from the
result set. It can only be used with SELECT statements.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.4. Using the ALTER command in Student_Moksh-
(i) ADD a column named AGE
(ii) MODIFY column ‘NAME’
(iii) DROP the column ‘CITY’

ALTER – It is used to add, modify, or drop/delete columns in a table. It can also be


used to rename a table.
SYNTAX:
ALTER TABLE table_name
ADD column_name
Column_definition;
(i)

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Using the select statement, we can see the changes as the Age column has been
added to the table.

Using the update statement, we have entered the age of all the students.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Using the SELECT statement, we can view the entire table with the updated
information.

SYNTAX:
ALTER TABLE table_name
MODIFY column_name column_type;
(ii)

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Using the DESC statement, we can see the changes made.

SYNTAX:
ALTER TABLE table_name
DROP COLUMN column_name;
(iii)

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.5. Rename the table name to Student_MokshArya.
SYNTAX:
ALTER TABLE table_name
RENAME TO new_table_name;

Q.6. Find out the names of all Students from Student_MokshArya.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.7. Retrieve Name, Class and Father_Name of all students from
Student_MokshArya.

Q.8. Change the class of Shreya, Mehak and Muskaan from BCom to BTech in
Student_MokshArya.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.9. Select the students’ details who are enrolled in the course BCom in
Student_MokshArya

Display just the Names of the students of class BCom

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
ASSIGNMENT 5

Q.1. Add a column named Telephone_Number data type number size 10 to


Employee_MokshEmp.

We can see the added column using the SELECT statement.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.2. Delete all Employees from the table whose Salary is 60000.
DELETE – It is used to delete a single record or multiple records from a table.
SYNTAX:
DELETE FROM table
[WHERE conditions];

We can see here that the records are deleted as per requirement.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.3. Sort the table Employee_MokshEmp on the basis of Name.

Q.4. Sort the table Employee_MokshEmp on the basis of Salary.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.5. Sort the table Employee_MokshEmp on the basis of Employee Number.

Q.6. Display Employee records whose Salary is greater than 50000.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.7. Display Employee records whose Designation is ‘HOD’.

Q.8. Display Employee records whose Department is ‘Administration’.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.9. Display Employee records whose Department is ‘Marketing’.

Q.10. Select Employee Name whose third character is ‘a’ and contains four
characters.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q.11. Add a column named Medical Leave.

Here we can see the added column.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
NAME : MOKSH ARYA
ENROLLMENT NUMBER : 01114788817
NAME : MOKSH ARYA
ENROLLMENT NUMBER : 01114788817
NAME : MOKSH ARYA
ENROLLMENT NUMBER : 01114788817
NAME : MOKSH ARYA
ENROLLMENT NUMBER : 01114788817
NAME : MOKSH ARYA
ENROLLMENT NUMBER : 01114788817
Q. Display all Employee records whose salary amount is ranging between 2000 and
4000 both inclusive.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q. Display Employees whose Designation is either ‘Manager’ or ‘Analyst’.

Q. Display Employees whose designation is either ‘Manager’ or ‘Clerk’ and Hiredate


is less than 10-JULY-2017.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q. Find the Average Commission of Employee_Moksh.

Q. Find the Minimum Commission of Employee_Moksh.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817
Q. Find the number of Designations in Employee_Moksh.

NAME : MOKSH ARYA


ENROLLMENT NUMBER : 01114788817

You might also like