0% found this document useful (0 votes)
2 views2 pages

Company Specific Questions

The document provides a series of SQL commands for managing a database, including creating, altering, renaming, and dropping tables. It details operations on employee and department records, such as inserting, updating, and deleting entries, as well as modifying data types and establishing foreign key relationships. Additionally, it includes commands for truncating and deleting records while maintaining the structure of the tables.

Uploaded by

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

Company Specific Questions

The document provides a series of SQL commands for managing a database, including creating, altering, renaming, and dropping tables. It details operations on employee and department records, such as inserting, updating, and deleting entries, as well as modifying data types and establishing foreign key relationships. Additionally, it includes commands for truncating and deleting records while maintaining the structure of the tables.

Uploaded by

pandurockzz962
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Company Specific Questions

1. Create a table named `employees` with columns: `id` (int), `name` (varchar),
`salary` (decimal), and `joining_date` (date).

2. Alter the `employees` table to add a new column `email` of type varchar(100).

3. Rename the `employees` table to `company_employees`.

4. Drop the `email` column from the `company_employees` table.

5. Create a table `departments` with columns: `dept_id` (int), `dept_name` (varchar).


Set `dept_id` as primary key.

6. Modify the `salary` column in the `employees` table to change its type to float.

7. Add a foreign key `dept_id` to the `employees` table referencing


`departments(dept_id)`.

8. Drop the table `departments`.

9. Truncate the table `company_employees`.


10. Create a table `projects` with fields `project_id` (int), `project_name` (varchar),
and ensure `project_id` is unique.

11. Insert a new record into the `employees` table with values (1, 'John Doe', 45000,
'2022-01-10').

12. Update the `salary` of employee with `id = 1` to 50000.

13. Delete the employee record where `name = 'John Doe'`.

14. Insert 3 different department records into the `departments` table.


15. Update all employees who joined before '2022-01-01' to have a salary of 60000.

16. Delete all employees whose salary is less than 30000.


17. Insert a new record in the `projects` table with project_id 101 and project_name
'AI System'.

18. Update the `project_name` of project with id 101 to 'AI Automation System'.

19. Insert a new employee and assign them to a department using the foreign key
`dept_id`.

20. Delete all records from the `employees` table without deleting the table itself.

You might also like