Oracle Semest 2 Part 1
Oracle Semest 2 Part 1
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Part I of the Semester 2 Final Exam covers Sections 8-9 of Database Programming
with SQL.
Section 8
1. Evaluate the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
Which statement should you use to increase the LAST_NAME column length to 35 if
the column currently contains 200 records?
Mark for Review
(1) Points
ALTER employees TABLE ALTER COLUMN (last_name VARCHAR2(35));
ALTER TABLE employees RENAME last_name VARCHAR2(35);
ALTER TABLE employees MODIFY (last_name VARCHAR2(35));
(*)
You CANNOT increase the width of the LAST_NAME column.
Correct
2. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
Which statement should you use to decrease the width of the FIRST_NAME column to
10 if the column currently contains 1500 records, but none are longer than 10 b
ytes or characters?
Mark for Review
(1) Points
ALTER players TABLE
MODIFY COLUMN first_name VARCHAR2(10);
ALTER players TABLE
You can issue this statement to retain the structure of the employees table.
(*)
You can reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE employees' statement
.
Correct
6. You need to remove all the rows from the SALES_HIST table. You want to rel
ease the storage space, but do not want to remove the table structure. Which sta
tement should you use? Mark for Review
(1) Points
The DROP TABLE statement
The ALTER TABLE statement
The DELETE statement
The TRUNCATE TABLE statement (*)
Correct
7. To do a logical delete of a column without the performance penalty of rewr
iting all the table datablocks you can issue the following command: Mark for Re
view
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column "columname"
Correct
8. You need to change the name of the EMPLOYEES table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employees emp;
RENAME employees TO emp; (*)
ALTER TABLE employees TO emp;
ALTER TABLE employees RENAME TO emp;
Correct
9. Examine the structure of the DONATIONS table.
DONATIONS:
PLEDGE_ID NUMBER
DONOR_ID NUMBER
PLEDGE_DT DATE
AMOUNT_PLEDGED NUMBER (7,2)
AMOUNT_PAID NUMBER (7,2)
PAYMENT_DT DATE
You need to reduce the precision of the AMOUNT_PLEDGED column to 5 with a scale
of 2 and ensure that when inserting a row into the DONATIONS table without a val
ue for the AMOUNT_PLEDGED column, a price of $10.00 will automatically be insert
ed. The DONATIONS table currently contains NO records. Which statement is true?
Mark for Review
(1) Points
You CANNOT decrease the width of the AMOUNT_PLEDGED column.
Both changes can be accomplished with one ALTER TABLE statement. (*)
You must drop and recreate the DONATIONS table to achieve these results.
You must use the ADD OR REPLACE option to achieve these results.
Correct
10. The previous administrator created a table named CONTACTS, which contains
outdated data. You want to remove the table and its data from the database. Whi
ch statement should you issue? Mark for Review
(1) Points
DROP TABLE (*)
DELETE
TRUNCATE TABLE
ALTER TABLE
Incorrect. Refer to Section 8 Lesson 3
Page 1 of 5
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Part I of the Semester 2 Final Exam covers Sections 8-9 of Database Programming
with SQL.
Section 8
11. The EMPLOYEES table contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
You need to remove the EMPLOYEE_ID column from the EMPLOYEES table. Which statem
ent could you use to accomplish this task?
Mark for Review
(1) Points
ALTER TABLE employees
MODIFY (employee_id NUMBER(5));
ALTER TABLE employees
DELETE employee_id;
ALTER TABLE employees
DROP COLUMN employee_id;
(*)
DELETE FROM employees
WHERE column = employee_id;
Correct
17. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the databa
se.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Correct
18. You need to store the SEASONAL data in months and years. Which data type
should you use? Mark for Review
(1) Points
DATE
TIMESTAMP
INTERVAL YEAR TO MONTH (*)
INTERVAL DAY TO SECOND
Correct
19. You want to create a table named TRAVEL that is a child of the EMPLOYEES
table. Which of the following statements should you issue? Mark for Review
(1) Points
CREATE TABLE travel
(destination_id primary key, departure_date date, return_date date, emp_id REFER
ENCES employees (emp_id));
CREATE TABLE travel
(destination_id number primary key, departure_date date, return_date date, t.emp
_id = e.emp_id);
CREATE TABLE travel
(destination_id number primary key, departure_date date, return_date date, JOIN
emp_id number(10) ON employees (emp_id));
CREATE TABLE travel
(destination_id number primary key, departure_date date, return_date date, emp_i
d number(10) REFERENCES employees (emp_id));
(*)
Correct
20. You are creating the EMPLOYEES table. This table should contain the COMMI
SSION_PCT column and use a value of 10 percent if no commission value is provide
d when a record is inserted. Which line should you include in the CREATE TABLE s
tatement to accomplish this task? Mark for Review
(1) Points
commission_pct NUMBER(4,2) DEFAULT 0.10 (*)
commission_pct NUMBER(4,2) DEFAULT = 0.10
commission_pct NUMBER(4,2) DEFAULT (0.10)
commission_pct NUMBER(4,2) (DEFAULT, 0.10)
Correct
Page 2 of 5
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Part I of the Semester 2 Final Exam covers Sections 8-9 of Database Programming
with SQL.
Section 8
21. Which column name is valid? Mark for Review
(1) Points
1NUMBER
NUMBER
NUMBER_1$ (*)
1_NUMBER#
Incorrect. Refer to Section 8
22. Which statement about table and column names is true? Mark for Review
(1) Points
Table and column names must begin with a letter. (*)
Table and column names can begin with a letter or a number.
Table and column names cannot include special characters.
If any character other than letters or numbers is used in a table or column
name, the name must be enclosed in double quotation marks.
Correct
23. Which CREATE TABLE statement will fail? Mark for Review
(1) Points
CREATE TABLE date_1 (date_1 DATE);
CREATE TABLE date (date_id NUMBER(9)); (*)
CREATE TABLE time (time_id NUMBER(9));
CREATE TABLE time_date (time NUMBER(9));
Correct
Section 9
24. Which statement about a FOREIGN KEY constraint is true? Mark for Review
(1) Points
An index is automatically created for a FOREIGN KEY constraint.
A FOREIGN KEY constraint requires the constrained column to contain values t
hat exist in the referenced Primary or Unique key column of the parent table. (*
)
A FOREIGN KEY constraint allows that a list of allowed values be checked bef
ore a value can be added to the constrained column.
A FOREIGN KEY column can have a different data type from the primary key col
umn that it references.
Correct
25. Which clause could you use to ensure that cost values are greater than 1.
00? Mark for Review
(1) Points
CONSTRAINT CHECK cost > 1.00
Correct
29. What is an attribute of data that is entered into a primary key column?
Mark for Review
(1) Points
Null and non-unique values cannot be entered into a primary key column. (*)
Data that is entered into a primary key column automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the sa
me datatype in another table.
Page 3 of 5
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Part I of the Semester 2 Final Exam covers Sections 8-9 of Database Programming
with SQL.
Section 9
31. You need to enforce a relationship between the LOC_ID column in the FACIL
ITY table and the same column in the MANUFACTURER table. Which type of constrain
t should you define on the LOC_ID column? Mark for Review
(1) Points
UNIQUE
NOT NULL
FOREIGN KEY (*)
PRIMARY KEY
Correct
35. Which constraint can only be created at the column level? Mark for Revie
w
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
36. Primary Key, Foreign Key, Unique Key and Check Constraints can be added a
t which two levels? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
Null Field
Table (*)
Row
Dictionary
Column (*)
Correct
37. Which two statements about NOT NULL constraints are true? (Choose two) M
ark for Review
(1) Points
(Choose all correct answers)
The Oracle Server creates a name for an unnamed NOT NULL constraint. (*)
A NOT NULL constraint can be defined at either the table or column level.
The NOT NULL constraint requires that every value in a column be unique.
Columns without the NOT NULL constraint can contain null values by default.
You CANNOT add a NOT NULL constraint to an existing column using the ALTER T
ABLE ADD CONSTRAINT statement. (*)
Correct
Correct
Page 4 of 5
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Part I of the Semester 2 Final Exam covers Sections 8-9 of Database Programming
with SQL.
Section 9
41. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES employees(emplo
yee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manage
r must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID t
o match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each e
mployee ID must be unique.
Correct
42. You need to remove the EMP_FK_DEPT constraint from the EMPLOYEES table in
your schema. Which statement should you use? Mark for Review
(1) Points
DROP CONSTRAINT EMP_FK_DEPT FROM employees;
DELETE CONSTRAINT EMP_FK_DEPT FROM employees;
ALTER TABLE employees DROP CONSTRAINT EMP_FK_DEPT; (*)
ALTER TABLE employees REMOVE CONSTRAINT EMP_FK_DEPT;
Correct
43. You need to add a PRIMARY KEY constraint on the EMP_ID column of the EMPL
OYEES table. Which ALTER TABLE statement should you use? Mark for Review
(1) Points
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
46. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
You need to disable the FOREIGN KEY constraint. Which statement should you use?
Mark for Review
(1) Points
ALTER TABLE line_item DISABLE CONSTRAINT product_id_fk; (*)
ALTER TABLE line_item DROP CONSTRAINT product_id_fk;
ALTER TABLE line_item ENABLE CONSTRAINT product_id_fk;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Incorrect. Refer to Section 9
47. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE; For which task would you issue this st
atement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
To drop and recreate the PRIMARY KEY constraint on the PO_NUM column
To disable the PRIMARY KEY and any FOREIGN KEY constraints that are dependen
t on the PO_NUM column (*)
To disable the constraint on the PO_NUM column while creating a PRIMARY KEY
index
Correct
48. You disabled the EMPLOYEE_ID_PK PRIMARY KEY constraint on the ID column i
n the EMPLOYEES table and imported 100 records. You need to enable the constrain
t and verify that the new and existing ID column values do not violate the PRIMA
RY KEY constraint. Evaluate this statement:
ALTER TABLE employees
ENABLE employee_id_pk;
Which statement is true?
Mark for Review
(1) Points
The statement will achieve the desired result.
The statement will execute, but will ensure that the new ID values are uniqu
e.
The statement will execute, but will not verify that the existing values are
unique.
The statement will NOT execute because it contains a syntax error. (*)
Correct
49. The DEPARTMENTS table contains these columns:
DEPARTMENT_ID NUMBER, Primary Key
DEPARTMENT_ABBR VARCHAR2(4)
DEPARTMENT_NAME VARCHAR2(30)
MANAGER_ID NUMBER
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
HIRE_DATE DATE
Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT REFERENTIAL (manager_id) TO departments(manager_id);
Which statement is true?
Mark for Review
(1) Points
The ALTER TABLE statement creates a referential constraint from the EMPLOYEE
S table to the DEPARTMENTS table.
The ALTER TABLE statement creates a referential constraint from the DEPARTME
NTS table to the EMPLOYEES table.
The ALTER TABLE statement fails because the ADD CONSTRAINT clause contains a
syntax error. (*)
The ALTER TABLE statement succeeds, but does NOT recreate a referential cons
traint.
Correct
50. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
Page 5 of 5