امتحان الميد ترم
Test: Final Exam Semester 2 - Part I
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8
(Answer all questions in this section)
1. You want to create a database table that will contain information regarding products that your company released during 2001. Which name can you assign to the table that you create? Mark for Review
(1) Points
2001_PRODUCTS
PRODUCTS_2001 (*)
PRODUCTS_(2001)
PRODUCTS--2001
Correct
2. Which statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema does not exist, it will be created.
Incorrect. Refer to Section 8 Lesson 1.
3. Which column name is valid? Mark for Review
(1) Points
1NUMBER
NUMBER
NUMBER_1$ (*)
1_NUMBER#
Correct
4. 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 REFERENCES 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_id number(10) REFERENCES employees (emp_id));
(*)
Correct
5. 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
6. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
1
2
3
4 (*)
Incorrect. Refer to Section 8 Lesson 1.
7. Your supervisor has asked you to modify the AMOUNT column in the ORDERS table. He wants the column to be configured to accept a default value of 250. The table constains data that you need to keep. Which statement should you issue to accomplish this task? Mark for Review
(1) Points
ALTER TABLE orders
CHANGE DATATYPE amount TO DEFAULT 250;
ALTER TABLE orders
MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders
(orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid),
orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders
(orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid),
orderdate date,
amount DEFAULT 250)
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. Evaluate the structure of the EMPLOYEE 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)
The EMPLOYEE_ID column currently contains 500 employee identification numbers. Business requirements have changed and you need to allow users to include text characters in the identification values. Which statement should you use to change this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee
MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee
REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE
MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not empty. (*)
Correct
10. You need to remove all the data in the SCHEDULE table, the structure of the table, and the indexes associated with the table. Which statement should you use? Mark for Review
(1) Points
DROP TABLE (*)
TRUNCATE TABLE
ALTER TABLE
DELETE TABLE
Test: Final Exam Semester 2 - Part I
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8
(Answer all questions in this section)
11. To do a logical delete of a column without the performance penalty of rewriting all the table datablocks you can issue the following command: Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column ?columname?
Correct
12. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
The TEAMS table is currently empty. You need to allow users to include text characters in the manager identification values. Which statement should you use to implement this?
Mark for Review
(1) Points
ALTER teams
MODIFY (mgr_id VARCHAR2(15));
ALTER TABLE teams
MODIFY (mgr_id VARCHAR2(15));
(*)
ALTER TABLE teams
REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE
MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Incorrect. Refer to Section 8 Lesson 3.
13. Which command could you use to quickly remove all data from the rows in a table without deleting the table itself? Mark for Review
(1) Points
ALTER TABLE
DROP TABLE
MODIFY
TRUNCATE TABLE (*)
Incorrect. Refer to Section 8 Lesson 3.
14. Comments on tables and columns can be stored for documentation by: Mark for Review
(1) Points
Embedding /* comment */ within the definition of the table.
Using the ALTER TABLE CREATE COMMENT syntax
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
15. You need to truncate the EMPLOYEES table. The EMPLOYEES table is not in your schema. Which privilege must you have to truncate the table? Mark for Review
(1) Points
The DROP ANY TABLE system privilege (*)
The TRUNCATE ANY TABLE system privilege
The CREATE ANY TABLE system privilege
The ALTER ANY TABLE system privilege
Correct
16. Evaluate this statement:
ALTER TABLE inventory
MODIFY backorder_amount NUMBER(8,2);
Which task will this statement accomplish?
Mark for Review
(1) Points
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8 2)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Incorrect. Refer to Section 8 Lesson 3.
17. Which statement about a column is NOT true? Mark for Review
(1) Points
You can increase the width of a CHAR column.
You can modify the data type of a column if the column contains non-null data. (*)
You can convert a CHAR data type column to the VARCHAR2 data type.
You can convert a DATE date type column to a VARCHAR2 column.
Incorrect. Refer to Section 8 Lesson 3.
18. A column that will be used to store binary data up to 4 Gigabyes in size should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
19. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a combination of both.
All employee identification values are only 6 digits so the column should be variable in length.
Description values can range from 0 to 30 characters so the column should be fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct
20. 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
I
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8
(Answer all questions in this section)
21. The SPEED_TIME column should store a fractional second value. Which data type should you use? Mark for Review
(1) Points
DATE
DATETIME
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
22. The ELEMENTS column is defined as:
NUMBER(6,4)
How many digits to the right of the decimal point are allowed for the ELEMENTS column?
Mark for Review
(1) Points
Zero
Two
Four (*)
Six
Correct
23. You are designing a table for the Sales department. You need to include a column that contains each sales total. Which data type should you specify for this column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
24. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Correct
Section 10
(Answer all questions in this section)
25. You need to create a composite primary key constraint on the EMPLOYEES table. Which statement is true? Mark for Review
(1) Points
The PRIMARY KEY constraint must be defined at the table level. (*)
A PRIMARY KEY constraint must be defined for each column in the composite primary key.
The PRIMARY KEY constraint must be defined for the first column of the composite primary key.
The PRIMARY KEY constraint must be defined at the table level and for each column in the composite primary key.
Incorrect. Refer to Section 10 Lesson 2.
26. What must exist on the Parent table before Oracle will allow you to create a FOREIGN KEY constraint from a Child table? Mark for Review
(1) Points
A FOREIGN KEY constraint allows the constrained column to contain values that exist in the primary key column of the parent table.
A PRIMARY or UNIQUE KEY constraint must exist on the Parent table. (*)
An index must exist on the Parent table
A CHECK constraint must exist on the Parent table.
Incorrect. Refer to Section 10 Lesson 2.
27. Which constraint type enforces uniqueness? Mark for Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
28. When creating the EMPLOYEES table, which clause could you use to ensure that salary values are 1000.00 or more? Mark for Review
(1) Points
CONSTRAINT CHECK salary > 1000
CHECK CONSTRAINT (salary > 1000)
CONSTRAINT employee_salary_min CHECK salary > 1000
CONSTRAINT employee_salary_min CHECK (salary >= 1000) (*)
CHECK CONSTRAINT employee_salary_min (salary > 1000)
Correct
29. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
6
7 (*)
8
9
Correct
30. 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 that 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 before a value can be added to the constrained column.
A FOREIGN KEY column can have a different data type from the primary key column that it references.
Incorrect. Refer to Section 10 Lesson 2.
Page 3 of 5
Test: Final Exam Semester 2 - Part I
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 10
(Answer all questions in this section)
31. You need to enforce a relationship between the LOC_ID column in the FACILITY table and the same column in the MANUFACTURER table. Which type of constraint should you define on the LOC_ID column? Mark for Review
(1) Points
UNIQUE
NOT NULL
FOREIGN KEY (*)
PRIMARY KEY
Incorrect. Refer to Section 10 Lesson 2.
32. When creating a referential constraint, which keyword(s) identifies the table and column in the parent table? Mark for Review
(1) Points
FOREIGN KEY
REFERENCES (*)
ON DELETE CASCADE
ON DELETE SET NULL
Correct
33. Which of the following best describes the function of a CHECK constraint? Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is created.
Correct
34. You need to ensure that the LAST_NAME column does not contain null values. Which type of constraint should you define on the LAST_NAME column? Mark for Review
(1) Points
CHECK
UNIQUE
NOT NULL (*)
PRIMARY KEY
Correct
35. You need to ensure that the LAST_NAME column only contains certain character values. No numbers or special characters are allowed.
Which type of constraint should you define on the LAST_NAME column? Mark for Review
(1) Points
CHECK (*)
UNIQUE
NOT NULL
PRIMARY KEY
Incorrect. Refer to Section 10 Lesson 1.
36. You need to add a NOT NULL constraint to the COST column in the PART table. Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part
MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part
MODIFY (cost CONSTRAINT part_cost_nn NOT NULL);
(*)
ALTER TABLE part
MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part
ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Correct
37. What is the highest number of NOT NULL constraints you can have on a table? Mark for Review
(1) Points
5
10
3
You can have as many NOT NULL constraints as you have columns in your table. (*)
Correct
38. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct
39. Which statement about the NOT NULL constraint is true? Mark for Review
(1) Points
The NOT NULL constraint must be defined at the column level. (*)
The NOT NULL constraint can be defined at either the column level or the table level.
The NOT NULL constraint requires a column to contain alphanumeric values.
The NOT NULL constraint prevents a column from containing alphanumeric values.
Correct
40. Primary Key, Foreign Key, Unique Key and Check Constraints can be added at which two levels? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
Null Field
Table (*)
Row
Dictionary
Test: Final Exam Semester 2 - Part I
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 10
(Answer all questions in this section)
41. You can view the columns used in a constraint defined for a specific table by looking at which data dictionary table? Mark for Review
(1) Points
USER_CONS_COLUMNS (*)
CONSTRAINTS_ALL_COLUMNS
SYS_DATA_DICT_COLUMNS
US_CON_SYS
Correct
42. You want to disable the FOREIGN KEY constraint that is defined in the EMPLOYEES table on the DEPARTMENT_ID column. The constraint is referenced by the name FK_DEPT_ID_01. Which statement should you issue? Mark for Review
(1) Points
ALTER TABLE employees
DISABLE 'fk_dept_id_01';
ALTER TABLE employees
DISABLE CONSTRAINT 'fk_dept_id_01';
ALTER TABLE employees
DISABLE fk_dept_id_01;
ALTER TABLE employees
DISABLE CONSTRAINT fk_dept_id_01;
(*)
Correct
43. You successfully create a table named SALARY in your company's database. Now, you want to establish a parent/child relationship between the EMPLOYEES table and the SALARY table by adding a FOREIGN KEY constraint to the SALARY table that references its matching column in the EMPLOYEES table. You have not added any data to the SALARY table. Which of the following statements should you issue? Mark for Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id)
REFERENCES employees (employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY
BETWEEN salary (employee_id) AND employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees (employee_id);
Correct
44. You need to add a NOT NULL constraint to the EMAIL column in the EMPLOYEES table. Which clause should you use? Mark for Review
(1) Points
ADD
CHANGE
MODIFY (*)
DISABLE
Correct
45. You need to add a PRIMARY KEY to the DEPARTMENTS table. Which statement should you use? Mark for Review
(1) Points
ALTER TABLE departments
ADD PRIMARY KEY dept_id_pk (dept_id);
ALTER TABLE departments
ADD CONSTRAINT dept_id_pk PK (dept_id);
ALTER TABLE departments
ADD CONSTRAINT dept_id_pk PRIMARY KEY (dept_id);
(*)
ALTER TABLE departments
ADD CONSTRAINT PRIMARY KEY dept_id_pk (dept_id);
Correct
46. What actions can be performed on or with Constraints? Mark for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
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 statement?
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 dependent on the PO_NUM column (*)
To disable the constraint on the PO_NUM column while creating a PRIMARY KEY index
Correct
48. Which statement should you use to add a FOREIGN KEY constraint to the DEPARTMENT_ID column in the EMPLOYEES table to refer to the DEPARTMENT_ID column in the DEPARTMENTS table? Mark for Review
(1) Points
ALTER TABLE employees
MODIFY COLUMN dept_id_fk FOREIGN KEY (department_id) REFERENCES departments(department_id);
ALTER TABLE employees
ADD CONSTRAINT dept_id_fk FOREIGN KEY (department_id) REFERENCES departments(department_id);
(*)
ALTER TABLE employees
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (department_id) REFERENCES departments(department_id);
ALTER TABLE employees
ADD FOREIGN KEY departments(department_id) REFERENCES (department_id);
Correct
49. When dropping a constraint, which keyword(s) specifies that all the referential integrity constraints that refer to the primary and unique keys defined on the dropped columns are dropped as well? Mark for Review
(1) Points
FOREIGN KEY
REFERENCES
CASCADE (*)
ON DELETE SET NULL
Correct
50. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(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.
Incorrect. Refer to Section 10 Lesson 3
Incorrect. Refer to Section 8 Lesson 3