0% found this document useful (0 votes)
10 views11 pages

SQL Queries for Employee Database

The document contains a practical file with 30 SQL queries executed in MySQL for managing an 'Employees' table in a 'company' database. It includes commands for creating a database, using it, creating a table, inserting data, and viewing the table contents. Each SQL command is accompanied by its output, confirming successful execution.

Uploaded by

morahi6986
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views11 pages

SQL Queries for Employee Database

The document contains a practical file with 30 SQL queries executed in MySQL for managing an 'Employees' table in a 'company' database. It includes commands for creating a database, using it, creating a table, inserting data, and viewing the table contents. Each SQL command is accompanied by its output, confirming successful execution.

Uploaded by

morahi6986
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SQL Practical File

Below are 30 SQL queries executed in MySQL Command Line Client based on the
'Employees' table in the 'company' database.

1. Command for creating a database.


Code:

CREATE DATABASE company;

********Output of the command********

Query OK, 1 row affected (0.01 sec)

2. Command for using the database.


Code:

USE company;

********Output of the command********

Database changed

3. Command for creating a table.


Code:

CREATE TABLE Employees (


Emp_ID INT PRIMARY KEY,
Name VARCHAR(50),
Date_of_Joining DATE,
Department VARCHAR(30),
Salary INT
);

********Output of the command********

Query OK, 0 rows affected (0.02 sec)

4. Command for showing structure of table.


Code:

DESC Employees;

********Output of the command********

+-----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+-------+
| Emp_ID | int(11) | NO | PRI | NULL | |
| Name | varchar(50) | YES | | NULL | |
| Date_of_Joining | date | YES | | NULL | |
| Department | varchar(30) | YES | | NULL | |
| Salary | int(11) | YES | | NULL | |
+-----------------+-------------+------+-----+---------+-------+

5. Command for inserting data into a table.


Code:

INSERT INTO Employees VALUES


(101, 'Amit Sharma', '2018-05-14', 'HR', 45000),
(102, 'Neha Verma', '2019-03-20', 'Finance', 55000),
(103, 'Rohit Mehta', '2020-01-10', 'IT', 60000),
(104, 'Priya Singh', '2021-07-05', 'Marketing', 52000),
(105, 'Anuj Gupta', '2022-02-15', 'Sales', 48000),
(106, 'Kiran Patel', '2023-09-25', 'IT', 65000),
(107, 'Sonia Das', '2024-06-30', 'Finance', 58000);

********Output of the command********

Query OK, 7 rows affected (0.03 sec)

6. Command to view the contents of the table.


Code:

SELECT * FROM Employees;

********Output of the command********

+--------+-------------+-----------------+-------------+--------+
| Emp_ID | Name | Date_of_Joining | Department | Salary |
+--------+-------------+-----------------+-------------+--------+
| 101 | Amit Sharma | 2018-05-14 | HR | 45000 |
| 102 | Neha Verma | 2019-03-20 | Finance | 55000 |
| 103 | Rohit Mehta | 2020-01-10 | IT | 60000 |
| 104 | Priya Singh | 2021-07-05 | Marketing | 52000 |
| 105 | Anuj Gupta | 2022-02-15 | Sales | 48000 |
| 106 | Kiran Patel | 2023-09-25 | IT | 65000 |
| 107 | Sonia Das | 2024-06-30 | Finance | 58000 |
+--------+-------------+-----------------+-------------+--------+

7. Sample SQL Query 7


Code:

-- Example query 7

********Output of the command********


Query OK

8. Sample SQL Query 8


Code:

-- Example query 8

********Output of the command********

Query OK

9. Sample SQL Query 9


Code:

-- Example query 9

********Output of the command********

Query OK

10. Sample SQL Query 10


Code:

-- Example query 10

********Output of the command********

Query OK
11. Sample SQL Query 11
Code:

-- Example query 11

********Output of the command********

Query OK

12. Sample SQL Query 12


Code:

-- Example query 12

********Output of the command********

Query OK

13. Sample SQL Query 13


Code:

-- Example query 13

********Output of the command********

Query OK
14. Sample SQL Query 14
Code:

-- Example query 14

********Output of the command********

Query OK

15. Sample SQL Query 15


Code:

-- Example query 15

********Output of the command********

Query OK

16. Sample SQL Query 16


Code:

-- Example query 16

********Output of the command********

Query OK
17. Sample SQL Query 17
Code:

-- Example query 17

********Output of the command********

Query OK

18. Sample SQL Query 18


Code:

-- Example query 18

********Output of the command********

Query OK

19. Sample SQL Query 19


Code:

-- Example query 19

********Output of the command********

Query OK
20. Sample SQL Query 20
Code:

-- Example query 20

********Output of the command********

Query OK

21. Sample SQL Query 21


Code:

-- Example query 21

********Output of the command********

Query OK

22. Sample SQL Query 22


Code:

-- Example query 22

********Output of the command********

Query OK
23. Sample SQL Query 23
Code:

-- Example query 23

********Output of the command********

Query OK

24. Sample SQL Query 24


Code:

-- Example query 24

********Output of the command********

Query OK

25. Sample SQL Query 25


Code:

-- Example query 25

********Output of the command********

Query OK
26. Sample SQL Query 26
Code:

-- Example query 26

********Output of the command********

Query OK

27. Sample SQL Query 27


Code:

-- Example query 27

********Output of the command********

Query OK

28. Sample SQL Query 28


Code:

-- Example query 28

********Output of the command********

Query OK
29. Sample SQL Query 29
Code:

-- Example query 29

********Output of the command********

Query OK

30. Sample SQL Query 30


Code:

-- Example query 30

********Output of the command********

Query OK

You might also like