DDL
DDL
Place the
syntax in a script called
lab9_1.sql, then execute the statement in the script to create the table.
Confirm that the table is
created.
DESCRIBE dept
2. Populate the DEPT table with data from the DEPARTMENTS table. Include only
columns that
you need.
3. Create the EMP table based on the following table instance chart. Place the
syntax in a script called
lab9_3.sql, and then execute the statement in the script to create the table.
Confirm that the
table is created.
DESCRIBE emp
4. Modify the EMP table to allow for longer employee last names. Confirm your
modification.
DESCRIBE emp
5. Confirm that both the DEPT and EMP tables are stored in the data dictionary.
(Hint:
USER_TABLES)
SELECT table_name
FROM user_tables
WHERE table_name IN (�DEPT�, �EMP�);
6. Create the EMPLOYEES2 table based on the structure of the EMPLOYEES table.
Include only
the EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY, and DEPARTMENT_ID columns.
Name the columns in your new table ID, FIRST_NAME, LAST_NAME, SALARY , and
DEPT_ID, respectively.
9. Add a comment to the DEPT and EMP table definitions describing the tables.
Confirm your
additions in the data dictionary.
COMMENT ON TABLE emp IS �Employee Information�;
COMMENT ON TABLE dept IS �Department Information�;
SELECT *
FROM user_tab_comments
WHERE table_name = �DEPT�
OR table_name = �EMP�;
10. Drop the FIRST_NAME column from the EMP table. Confirm your modification by
checking the
description of the table.
DESCRIBE emp
11. In the EMP table, mark the DEPT_ID column in the EMP table as UNUSED. Confirm
your
modification by checking the description of the table.
DESCRIBE emp
12. Drop all the UNUSED columns from the EMP table. Confirm your modification by
checking the
description of the table.
ALTER TABLE emp
DROP UNUSED COLUMNS;
DESCRIBE emp