ISM Govind Singh
ISM Govind Singh
ISM Govind Singh
OF
INFORMATION SYSTEM MANAGEMENT LAB (BBA 212)
1. CREATE TABLE: This command is used to create a new table in SQL. The user
must give information like table name, column names, and their data types.
SYNTAX:
CREATE TABLE <table_name>
(column_1 datatype,
column_2 datatype,
column_3 datatype);
EXAMPLE:
CREATE TABLE <Student_info>
(College_Id int,
College_name varchar(30),
Branch varchar(10));
2. ALTER TABLE: This command is used to add, delete, or change columns in the
existing table. The user needs to know the existing table name and can do add,
delete, or modify tasks easily.
SYNTAX: To add a column to an existing table.
ALTER TABLE <table_name>
ADD column_namedatatype;
EXAMPLE:
ALTER TABLE Student ADD Father's_Name VARCHAR(60);
3. DROP TABLE: It is used to delete both the structure and record stored in the
table.
SYNTAX:
DROP TABLE <table_name>;
EXAMPLE:
DROP TABLE Student;
4. TRUNCATE TABLE: It is used to delete all the rows from the table and free the
space containing the table.
SYNTAX:
TRUNCATE TABLE <table_name>;
EXAMPLE:
TRUNCATE TABLE Student;
5. RENAME TABLE: RENAME TABLE allows you to rename an existing table
in any schema. To rename a table, you must either be the database owner or the
table owner.
SYNTAX:
RENAME <old_table _name> TO <new_table_name>;
EXAMPLE:
RENAME student TO Student_Table;
EXAMPLE:
1. SELECT Emp_Id, Emp_Salary FROM Employee;
2. SELECT * FROM Student;
5. MERGE: Merge in SQL merges two tables, a TARGET table, and a SOURCE
table, to form a single TARGET table where entries are INSERTED, DELETED,
or UPDATED based on their presence or absence on the source table.
CLAUSES: It is a built-in function that is used to retrieve the data from the records
present in the database. Different clauses in SQL are used to fetch or retrieve the records
from the database table.
Examples: ORDER BY, GROUP BY, WHERE, AND, OR.
DESC: The ORDER BY keyword sorts the records in ascending order by default.
To sort the records in descending order, use the DESC keyword.
SYNTAX:
SELECT * FROM <table_name>
ORDER BY <column_name> DESC ;
EXAMPLE:
SELECT * FROM Students
ORDER BY Roll_no DESC;
2. GROUP BY:It groups rows that have the same values into summary rows. It is
often used with aggregate functions like COUNT(), MAX(), MIN(), SUM(),
AVG() to group the result-set by one or more columns.
SYNTAX:
SELECT <column_name>
FROM <table_name>
WHERE <condition>
GROUP BY <column_name>
ORDER BY <column_name>;
EXAMPLE:
QUES 2. Create a local template of "FACULTY", insert 5 records and perform the
following queries on faculty template table:
a. Insert five records using "new faculty" tab in faculty template.
b. Faculty name should be in ascending order.
c. Department should be in descending order.
d. Generate report for: All faculty category and faculty by department category.
ANS.
Use mysql
Show databases
Show tables
Desc ‘Faculty’.
a. Insert five records using "new faculty" tab in faculty template.
d. Generate report for: All faculty category and faculty by department category.
Use mysql.
Show databases.
Show tables.
(c) Display the name of the employee whose contact no. is 456.
(d) Display the details of the employee whose address is Chhatarpur.
(e) Display the name of the employees whose salary is greater than 3,00,000.
(f) Update the employee details, set EMP GRADE equal to 3 whose salary is less
than 1,00,000.
(g) Delete the record of the employee whose gender is male and designation is
Financial Analyst.
(h) Display the name, designation, and salary of all the employees whose names
begins with A.
(i) Update the employee details, set designation to Assistant Manager where
designation is Librarian.
We have a set of teams, each team has an ID (unique identifier), name, main
stadium, and to which city this team belongs.
Each team has many players, and each player belongs to one team. Each
player has a number (unique identifier), name, DOB, start year, and shirt
number that he uses.
Teams play matches, in each match there is a host team and a guest team. The
match takes place in the stadium of the host team.
For each match we need to keep track of the following:
The date on which the game is played
The final result of the match
The players participated in the match. For each player, how many goals he
scored, whether or not he took yellow card, and whether or not he took red
card.
During the match, one player may substitute another player. We want to
capture this substitution and the time at which it took place.
Each match has exactly three referees. For each referee we have an ID
(unique identifier), name, DOB, years of experience. One referee is the main
referee and the other two are assistant referee.
Design an ER diagram to capture the above requirements. State any assumptions
you have that affects your design (use the back of the page if needed). Make sure
cardinalities and primary keys are clear.
QUES 5. Create a table Employee to store employee details as shown below and
write statements for following queries based on the table.
Consider the Employee table and write SQL command to get the following.
a. Write a query to display Ename and Sal of employees whose salary are greater
than or equal to 2200?
b. Write a query to display details of employees who are not getting commission?
c. Write a query to display employee name and salary of those employees who don’t
have their salary in range of 2500 to 4000?
d. Write a query to display the name, job title and salary of employees who don’t
have manager?
e. Write a query to display the name of employee whose name contains “A” as third
alphabet?
f. Write a query to display the name of employee whose name contains “T” as last
alphabet?
g. Write a query to display the name of employee whose name contains ”M” as First
and “L” as third alphabet?
Use mysql and show databases.
Show tables.
CREATE TABLE Employee.
a. Write a query to display E_name and Salary of employees whose salary are
greater than or equal to 2200.
b. Write a query to display details of employees who are not getting commission?
c. Write a query to display employee name and salary of those employees who don’t
have their salary in range of 2500 to 4000?
d. Write a query to display the name, job title and salary of employees who don’t
have manager?
e. Write a query to display the name of employee whose name contains ‘A’ as third
alphabet?
f. Write a query to display the name of employee whose name contains ‘T’ as last
alphabet?
g. Write a query to display the name of employee whose name contains ‘M’ as First
and ‘L’ as third alphabet?
OR
QUES 6. Create a table Student with following fields:
Enrolment_No.
S_Name
Course_ID
Batch
Semester
Execute the following queries after entering 10 records in the table.
a. Display the list of Students in Batch ‘2017-2020’.
b. Display the Enrolment No of 4th semester students.
c. Display the list of students of batch ‘2019-2022’ and Course_ID 17.
d. Display the number of students in Course_ID 44.
Use mysql
Show databases
Show tables
CREATE TABLE Student
INSERT INTO Student