Using the SQL table data from this question: https://www.chegg.com/homework-help
ID: 3915922 • Letter: U
Question
Using the SQL table data from this question:
https://www.chegg.com/homework-help/questions-and-answers/create-department-tables-based-following-column-name-id-name-data-type-number-varchar2-len-q30116538
Answe the following.
- Add a foreign key reference on the EMPLOYEE table that will ensure that the employee is not assigned to a nonexistent department.
- Confirm that the constraints were added by querying USER_CONSTRAINTS. Note the types and names of the constraints and include them in your statement comments.
- Display the object names and types from the USER_OBJECTS data dictionary view for EMPLOYEE and DEPARTMENT tables. You will want to format the columns for readability. Provide comments that include the new tables and indexes created.
- Modify the EMPLOYEE table by adding a SALARY column of NUMBER data type, precision 7.
Explanation / Answer
1.ALTER TABLE EMPLOYEE ADD CONSTRAINT add_fk FOREIGN KEY (dept_id) REFERENCES department (id);
2.
SELECT constraint_name, constraint_type FROM USER_CONSTRAINTS WHERE table_name IN('EMPLOYEE', 'DEPARTMENT');
4.
ALTER TABLE EMPLOYEE ADD (SALARY NUMBER (7));
3.
COLUMN object_name FORMAT A30
COLUMN object_name FORMAT A30
SELECT object_name,object_type FROM user_objects WHERE object_name LIKE 'EMPLOYEE%' OR onject_name LIKE 'DEPARTMENT%';
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.