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

MySQL database creation and tables checking

1. .Now create database using the following command

2. Now use the database enter this command

EXPERIMENT-1
Create a table STUDENT with appropriate data types and perform the
following queries.
regd no, student name, date of birth, branch and year of study.
a. Insert 5 to 10 rows in a table
b. List all the students of all branches
c. List student names whose name starts with ‘s’
d. List student names whose name contains ‘s’ as third literal
e. List student names whose contains two ‘s’ anywhere in the name
f. List students whose branch is NULL
g. List students of AIML who born after 1985.
h. List all students in reverse order of their names
i. Delete students of any branch whose name starts with ‘s’
j. Display student name padded with ‘*’ after the name of all the
Students.
STUDENT TABLE CREATION:

1
a. Insert 5 to 10 rows in a table.

2
b. List all the students of all branches.

c. List student names whose name starts with ‘s’

d. List student names whose name contains ‘s’ as third literal

e. List student names whose contains two ‘s’ anywhere in the name

3
f. List students whose branch is NULL

g. List students of AIML who born after 1985.

h. List all students in reverse order of their names

i. Delete students of any branch whose name starts with ‘s’

4
j. Display student name padded with ‘*’ after the name of all the
students

5
EXPERIMENT-2
Create the following tables with appropriate data typesand constraints.

EMPLOYEE (Fname, Mname, Lname, SSN, Bdate, Address, Gender, Salary,


SuperSSN,Dno)

DEPARTMENT (Dnumber, Dname, MgrSSN, Mgrstartdate)

DEPENDENT (ESSN, Dependent_Name, Gender, Bdate, Relationship)

a. Insert 5 to 10 rows into all the tables.


b. Display all employee’s names along with their department names.
c. Display all employee’s names along with their dependent details.
d. Display name and address of all employees who work for ‘AIML’
department.
e. List the names of all employees with two or more dependents.
f. List the names of employee who have no dependents.
g. List the names of employees who have at least one dependent.
h. List the names of the employees along with names of their supervisors
using aliases.
i. Display name of the department and name of manager for all the
departments.
j. Display the name of each employee who has a dependent with the same
first name and gender as the employee.
k. List the names of managers who have at least one dependent.

l. Display the sum of all employees’ salaries as well as maximum, minimum


and average salary in the entire departments department wise if the
department has more than two employees.
m. List the departments of each female employee along with her name.
n. List all employee names and also the name of the department they
manage if they happen to manage a dept

6
CREATING TABLES:

EMPLOYEE TABLE CREATION:

DEPARTMENT TABLE CREATION:

DEPENDENT TABLE CREATION:

7
a. Insert 5 to 10 rows into all the tables.
INSERT INTO EMPLOYEE:
INSERT INTO EMPLOYEE (FNAME, MNAME, LNAME, SSN, BDATE,
ADDRESS, GENDER, SALARY, SUPERSSN, DNO)
VALUES(‘SAI’,’MANIKANTA’,’T’,’40020511’,’1980-08-
08’,’HYDERABAD’,’M’,’20000,’40020511’,1);
…………………………………..
EMPLOYEE TABLE:

INSERT INTO DEPARTMENT1:


INSERT INTO DEPARTMENT1(DNUMBER, DNAME, MGRSSN,
MGRSTARTDATE) VALUES(1,’AIML’,’40020511’,’2002-07-26’);
…………………………………………………….
DEPARTMENT1 TABLE:

8
INSERT INTO DEPENDENT:
INSERT INTO DEPENDENT (ESSN, DEPENDENT_NAME, GENDER, BDATE,
RELATIONSHIP) VALUES(’40020511’,’GANDHI’,’M’,’1965-09-07’,’FATHER’);
………………………………………………
DEPENDENT TABLE:

b. Display all employee’s names along with their department names.

9
c. Display all employee’s names along with their dependent details.

d. Display name and address of all employees who work for ‘AIML’
department.

1
0
e. List the names of all employees with two or more dependents.

f. List the names of employee who have no dependents.

g. List the names of employees who have at least one dependent.

1
1
h. List the names of the employees along with names of their supervisors
using aliases.

i. Display name of the department and name of manager for all the
departments.

1
2
j. Display the name of each employee who has a dependent with the
same first name and gender as the employee.

k. List the names of managers who have at least one dependent.

l. Display the sum of all employees’ salaries as well as maximum,


minimum and average salary in the entire departments department wise
if the department has more than two employees.

1
3
m. List the departments of each female employee along with her name.

n. List all employee names and also the name of the department they
manage if they happen to manage a dept

1
4
1
5

You might also like