0% found this document useful (0 votes)
150 views

Exercises DDL Command

The document contains the structure of 5 tables (Location, Countries, Job, Job_History) and 13 MySQL statements to manipulate the tables. The statements create, alter, rename and drop the tables to practice DDL commands.

Uploaded by

Nice Don
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)
150 views

Exercises DDL Command

The document contains the structure of 5 tables (Location, Countries, Job, Job_History) and 13 MySQL statements to manipulate the tables. The statements create, alter, rename and drop the tables to practice DDL commands.

Uploaded by

Nice Don
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

Experiment-2

DDL Command Exercise


Location Table
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| LOCATION_ID | decimal(4,0) | YES | | NULL | |
| STREET_ADDRESS | varchar(40) | YES | | NULL | |
| POSTAL_CODE | varchar(12) | YES | | NULL | |
| CITY | varchar(30) | YES | | NULL | |
| STATE_PROVINCE | varchar(25) | YES | | NULL | |
| COUNTRY_ID | varchar(2) | YES | | NULL | |
+----------------+--------------+------+-----+---------+-------+

1. Write a MySql statement to create a simple table location as shown above

Countries Table

+--------------+---------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |


+--------------+---------------+------+-----+---------+-------+
| COUNTRY_ID | varchar(2) | YES | | NULL | |
| COUNTRY_NAME | varchar(40) | YES | | NULL | |
| REGION_ID | decimal(10,0) | YES | | NULL | |
+--------------+---------------+------+-----+---------+-------+

2. Write a MySql statement to create a simple table countries as shown above.

Job Table

+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| JOB_ID | varchar(10) | NO | | NULL | |
| JOB_TITLE | varchar(35) | NO | | NULL | |
| MIN_SALARY | decimal(6,0) | YES | | NULL | |
| MAX_SALARY | decimal(6,0) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+

3. Write a MySql statement to create a simple table Job as shown above


Job_History Table

+---------------+--------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |


+---------------+--------------+------+-----+---------+-------+
| EMPLOYEE_ID | decimal(6,0) | NO | | NULL | |
| START_DATE | date | NO | | NULL | |
| END_DATE | date | NO | | NULL | |
| JOB_ID | varchar(10) | NO | | NULL | |
| DEPARTMENT_ID | decimal(4,0) | NO | | NULL | |
+---------------+--------------+------+-----+---------+-------+

4. Write a MySql statement to create a simple table Job_History as shown above

5. Write a MySql statement to rename the table countries to country_new.

6. Write a MySql statement to add a column region_id to the table locations.

7. Write a MySql statement to add a columns ID as the first column of the table
locations.

8. Write a MySql statement to add a column region_id after state_province to


the table locations.

9. Write a MySql statement change the data type of the column country_id to
integer in the table locations.

10. Write a MySql statement to drop the column city from the table locations.

11. Write a MySql statement to change the name of the column state_province to
state, keeping the data type and size same.

12. Write a MySql statement to drop table Job_History.

13. Write a MySql statement to truncate table Job_History.

You might also like