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

DDL CommandsHR Database SQL Practice Workbook

The document outlines SQL DDL commands for creating and modifying tables in an HR database. It includes instructions for creating tables such as Interns, Project_Assignments, and Training, as well as altering existing tables by adding, modifying, or dropping columns. Additionally, it provides commands for renaming tables and clarifies the data types used for numeric columns.

Uploaded by

Sakshi Prajapati
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)
4 views2 pages

DDL CommandsHR Database SQL Practice Workbook

The document outlines SQL DDL commands for creating and modifying tables in an HR database. It includes instructions for creating tables such as Interns, Project_Assignments, and Training, as well as altering existing tables by adding, modifying, or dropping columns. Additionally, it provides commands for renaming tables and clarifies the data types used for numeric columns.

Uploaded by

Sakshi Prajapati
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

HR Database SQL Practice Workbook

DDL Commands
1. CREATE
1. Create a table Interns with columns: intern_id (NUMBER), first_name
(VARCHAR2(20)), last_name (VARCHAR2(25)), department_id (NUMBER), stipend
(NUMBER(8,2)).
2. Create a table Project_Assignments with columns: project_id (NUMBER),
employee_id (NUMBER), role (VARCHAR2(30)), start_date (DATE), end_date
(DATE).
3. Create a table Training with columns: training_id (NUMBER), training_name
(VARCHAR2(50)), duration_days (NUMBER), trainer_name (VARCHAR2(40)).
4. Create a table Department_Backup with the same structure as Departments table
(no data).
5. Create a table Salary_Grades with columns: grade_level (CHAR(1)), min_salary
(NUMBER), max_salary (NUMBER).
6. Create a table Branch with columns: branch_id (NUMBER), branch_name
(VARCHAR2(30)), location_id (NUMBER).
7. Create a table Archived_Employees with the same structure as Employees table
(no data).

2. ALTER
8. Add a new column email (VARCHAR2(50)) to the Interns table.
9. Modify the stipend column in Interns table to allow 4 decimal places.
10. Add a column bonus (NUMBER(8,2)) to the Employees table.
11. Modify phone_number in Employees to increase its size to VARCHAR2(30).
12. Rename column role in Project_Assignments to job_role.
13. Rename column duration_days in Training to course_days.
14. Drop the column end_date from Project_Assignments.
15. Drop the column bonus from Employees.

16. Drop the table Interns.


17. Truncate the Job_History table (keep structure, delete rows).
RENAME
18. Rename the table Interns to Student_Interns.
19. Rename the table Project_Assignments to Employee_Projects.
20. Rename the table Department_Backup to Dept_Backup_2025.
21. Rename the table Archived_Employees to Old_Employees.

Note:
NUMBER alone → means it can store any number up to 38 digits (precision up to
38, scale floating).

You might also like