Teste SQL
Teste SQL
1.
You need to display each employee's name in all uppercase letters. Which function should you use?
CASE
UCASE
UPPER (*)
TOUPPER
2.
SUBSTR
LOWER (*)
CONCAT
INSTR (*)
LENGTH
4.
SUBSTR
Which three statements about functions are true? (Choose three.)
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
5.
PRODUCT_ID MANUFACTURER_ID
86950 59604
You query the database and return the value 95. Which script did you use?
SELECT SUBSTR(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
(*)
SELECT LENGTH(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
LPAD
COUNT
SUBSTR
7.
13 (*)
17
8.
1200
1282
1282.25
1300 (*)
9.
25
10.
Which two functions can be used to manipulate number or date column values, but NOT character
column values? (Choose two.)
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
11.
You need to display the current year as a character value (for example: Two Thousand and One).
Which element would you use? Mark for Review
(1) Points
RR
YY
YYYY
YEAR (*)
12.
Which SELECT statement will NOT return a date value? Mark for Review
(1) Points
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
14.
You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should you
issue?
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Section 2 Lesson 1
16.
Which three statements concerning explicit data type conversions are true? (Choose three.)
(Choose all correct answers)
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number. (*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string. (*)
17.
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script should you use to display
the salaries in format: "$45,000.00"?
FROM employees;
(*)
18.
Single row functions can accept only one argument, but can return multiple values.
19.
Which SQL Statement should you use to display the prices in this format: "$00.30"?
20.
The TO_CHAR function can be used to specify meaningful column names in an SQL statement's
result set.
The TO_CHAR function can be used to remove text from column data that will be returned by the
database.
The TO_CHAR function can be used to display dates and numbers according to formatting
conventions that are supported by Oracle. (*)
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
HIRE_DATE DATE
You need to display HIRE_DATE values in this format:
January 28, 2000
Which SELECT statement could you use?
Section 2 Lesson 2
22.
Which of the following General Functions will return the first non-null expression in the expression list?
NVL
NVL2
NULLIF
COALESCE (*)
23.
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
24.
STYLE_ID
895840
968950
869506
809090
890890
857689
758960
STYLE_NAME
SANDAL
SANDAL
SANDAL
LOAFER
LOAFER
HEEL 85940
SANDAL
CATEGORY
85940 12.00
85909 10.00
89690 15.00
89098 10.00
89789 14.00
11.00
86979
COST
STYLE_ID
895840
968950
758960
STYLE_NAME
SANDAL
SANDAL
SANDAL
CATEGORY
85940 12.00
85909 10.00
86979
COST
STYLE_ID
STYLE_NAME
895840
SANDAL
968950 SANDAL
85909
869506
SANDAL
758960
SANDAL
CATEGORY
85909 12.00
10.00
89690 15.00
86979
COST
STYLE_ID
895840
968950
758960
869506
STYLE_NAME
SANDAL
SANDAL
SANDAL
SANDAL
CATEGORY
85909 12.00
85909 10.00
86979
89690 15.00
COST
STYLE_ID
968950
895840
758960
STYLE_NAME
SANDAL
SANDAL
SANDAL
CATEGORY
85909 10.00
85940 12.00
86979
COST
(*)
Section 3 Lesson 2
25.
When joining 3 tables in a SELECT statement, how many join conditions are needed in the WHERE
clause?
Mark for Review
(1) Points
2 (*)
26.
28.
ORDER BY 4;
29.
You need to create a report that lists all employees in department 10 (Sales) whose salary is not
equal to $25,000 per year. Which query should you issue to accomplish this task?
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND department_id = 10;
30.
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
All rows that do not match in the WHERE clause are displayed
31.
Outer joins are always evaluated before other types of joins in the query.
32.
The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID column of
the ORDERS table. The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you
need to display.
Which type of join should you use to display the data?
natural join
self-join
equijoin
33.
Using Oracle Proprietary join syntax, which two operators can be used in an outer join condition using
the outer join operator (+)?
OR and =
BETWEEN...AND... and IN
IN and =
Section 4 Lesson 2
34.
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
35.
36.
A cross referenced result omitting similar fields from the two tables.
Section 4 Lesson 3
37.
For which condition would you use an equijoin query with the USING keyword?
You need to perform a join of the CUSTOMER and ORDER tables but limit the number of columns in
the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column in the PRODUCT
table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID column
in the ORDER table contains null values that need to be displayed.
38.
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you use?
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
39.
The join happens automatically based on matching column names and data types
40.
SELECT a.last_name || ', ' || a.first_name as "Patient", b.last_name || ', ' || b.first_name as "Physician",
c.admission
FROM patient a
JOIN physician b
ON (b.physician_id = c.physician_id)
JOIN admission c
ON (a.patient_id = c.patient_id);
Which clause generates an error?
JOIN physician b
JOIN admission c
ON (a.patient_id = c.patient_id)
41.
What should be included in a SELECT statement to return NULL values from all tables?
natural joins
42.
Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table?
Which type of join returns rows from one table that have NO direct match in the other table?
equijoin
self join
natural join
Section 5 Lesson 1
44.
The hire dates in the EMPLOYEES table that contain NULL values.
45.
The last column listed in the GROUP BY clause is the most major grouping.
46.
47.
Displays each job id and the number of people assigned to that job id. (*)
Displays all the jobs with as many people as there are jobs.
Section 5 Lesson 2
48.
Which group function would you use to display the lowest value in the SALES_AMOUNT column?
AVG
COUNT
MAX
MIN (*)
49.
Group functions return a value for ________________ and ________________ null values in their
computations.
50.
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(9,2)
HIRE_DATE DATE
BONUS NUMBER(7,2)
COMM_PCT NUMBER(4,2)
Which three functions could be used with the HIRE_DATE, LAST_NAME, or SALARY columns? (Choose
three.)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
51.
Which group function would you use to display the total of all salary values in the EMPLOYEE table?
SUM (*)
AVG
COUNT
MAX
52.
You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use?
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
53.
You need to calculate the average salary of employees in each department. Which group function will
you use?
AVG (*)
MEAN
MEDIAN
AVERAGE
54.
You need to compute the total salary for all employees in department 10. Which group function will
you use?
MAX
SUM (*)
VARIANCE
COUNT
55.
Which aggregate function can be used on a column of the DATE data type?
AVG
MAX (*)
STDDEV
SUM
Section 5 Lesson 3
56.
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the AMOUNT column is
not null. (*)
57.
Which SELECT statement will calculate the number of rows in the PRODUCTS table?
SELECT COUNT(products);
58.
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000? Which SELECT would
you use?
SELECT * FROM employees
WHERE salary > 50000;
59.
LINE_ITEM_ID
890898
768385
867950
954039
543949
ORDER_ID
847589
862459
985490
439203
349302
PRODUCT_ID
848399
849869
945809
438925
453235
PRICE
8.99
5.60
5.60
5.25
4.50
DISCOUNT
0.10
0.05
0.15
You query the LINE_ITEM table and a value of 3 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
Section 6 Lesson 1
60.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
61.
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
62.
You want to write a report that returns the average salary of all employees in the company, sorted by
departments. The EMPLOYEES table contains the following columns:
EMPLOYEES:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
63.
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
SELECT
FROM
WHERE
GROUP BY (*)
64.
65.
PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category by location. You need to include only the
products that have a price less than $25.00. The extended cost of each item equals the quantity value
multiplied by the cost value.
Which SQL statement will display the desired result?
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
66.
To exclude rows before dividing them into groups using the GROUP BY clause, you should use a
WHERE clause. (*)
You must use the HAVING clause with the GROUP BY clause.
67.
PLAYERS
PLAYER_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
TEAM_ID NUMBER
POSITION VARCHAR2 (25)
TEAMS
TEAM_ID NUMBER NOT NULL, Primary Key
TEAM_NAME VARCHAR2 (25)
You need to create a report that lists the names of each team with more than three goal keepers.
Which SELECT statement will produce the desired result?
EMPLOYEES
EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(30)
LAST_NAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative named Franklin during the
year 2001?
SELECT (SELECT employee_id FROM employees WHERE last_name = 'Franklin') AND order_id,
total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
69.
Using a subquery in which of the following clauses will return a syntax error?
WHERE
FROM
HAVING
70.
71.
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
72.
Which operator can be used with subqueries that return only one row?
LIKE (*)
ANY
ALL
IN
Section 6 Lesson 3
73.
EMPLOYEE
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
DEPARTMENT
DEPARTMENT_ID NUMBER(9)
DEPARTMENT_NAME VARCHAR2(25)
CREATION_DATE DATE
ORDERS
ORDER_ID NUMBER(9)
EMPLOYEE_ID NUMBER(9)
DATE DATE
CUSTOMER_ID NUMBER(9)
You want to display all employees who had an order after the Sales department was established. Which of the
following constructs would you use?
a group function
a MERGE statement
74.
EMPLOYEES
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
SUPERVISOR_ID NUMBER(9)
You need to produce a report that contains all employee-related information for those employees who have
Brad Carter as a supervisor. However, you are not sure which supervisor ID belongs to Brad Carter. Which
query should you issue to accomplish this task?
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT employee_id
FROM supervisors
WHERE last_name = 'Carter');
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT employee_id
FROM employees
WHERE last_name = 'Carter');
(*)
75.
a query that returns only one row from the inner SELECT statement (*)
a query that returns one or more rows from the inner SELECT statement
a query that returns only one column value from the inner SELECT statement
a query that returns one or more column values from the inner SELECT statement
Section 6 Lesson 4
76.
Which best describes a multiple-row subquery? Mark for Review
(1) Points
A query that returns only one row from the inner SELECT statement
A query that returns one or more rows from the inner SELECT statement (*)
A query that returns only one column value from the inner SELECT statement
A query that returns one or more column values from the inner SELECT statement
77.
Subquery returns more than one row and single row comparison operator is used. (*)
78.
Only the rows with CUSTOMER_ID values equal to null would be selected.
79.
All employees who work in a department with employees who earn more than $30,000 and more than
$50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
80.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
81.
Which of the following statements contains a comparison operator that is used to restrict rows based
on a list of values returned from an inner query? Mark for Review
(1) Points
SELECT description
FROM d_types
WHERE code IN (SELECT type_code FROM d_songs);
SELECT description
FROM d_types
WHERE code = ANY (SELECT type_code FROM d_songs);
SELECT description
FROM d_types
WHERE code <> ALL (SELECT type_code FROM d_songs);
82.
Only one
Two or more
None
83.
What would happen if you attempted to use a single-row operator with a multiple-row subquery?
ANY
= (*)
>
85.
You need to display all the products that cost more than the maximum cost of every product produced
in Japan. Which multiple-row comparison operator could you use?
>ANY (*)
NOT=ALL
IN
>IN
86.
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but used to be in department 15.
Which query should you use?
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, new_dept_id
 FROM depart_hist
 WHERE old_dept_id = 15) AND new_dept_id = 10;
(*)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
 FROM employee_hist
 WHERE old_dept_id = 15);
Section 7 Lesson 1
87.
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)
You want to add the following row data to the PRODUCTS table:
(1) a NULL value in the PROD_ID column
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column
You issue this statement:
INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);
What row data did you add to the table?
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.
The row was created with the correct data in one of the three columns.
The row was created completely wrong. No data ended up in the correct columns.
89.
You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
(Choose all correct answers)
90.
If no column list is specified, then the values must be in the order the columns are specified in the
table. (*)
Character, date, and numeric data must be enclosed within single quotes in the VALUES clause.
To specify a null value in the VALUES clause, use an empty string (' ').
91.
You need to update the area code of employees that live in Atlanta . Evaluate this partial UPDATE
statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the desired results?
LIKE 'At%';
92.
What would happen if you issued a DELETE statement without a WHERE clause?
93.
You need to delete a record in the EMPLOYEES table for Tim Jones, whose unique employee
identification number is 348. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(5) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
94. Which two commands can be used to modify existing data in a database row?
(Choose all correct answers)
DELETE
MERGE (*)
SELECT
UPDATE (*)
95.
When the WHERE clause is missing in a DELETE statement, what is the result?
96.
Which of the following represents the correct syntax for an INSERT statement?
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';
INSERT INTO customers VALUES (3178, 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777'); (*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
97.
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id = 10);
98.
You want to enter a new record into the CUSTOMERS table. Which two commands can be used to
create new rows?
INSERT, CREATE
MERGE, CREATE
INSERT, UPDATE
99.
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
100.
Evaluate this statement: DELETE FROM customer; Which statement is true?
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
The statement removes the structure of the CUSTOMER table from the database.
Section 8 Lesson 1
1. You are creating the EMPLOYEES table. This table should
contain the COMMISSION_PCT column and use a value of 10 percent if nocommission value is provided
when a record is inserted. Which line shouldyou include in the CREATE TABLE statement to accomplish this
task?
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)
You are a member of the SYSDBA role, but are not logged in as SYSDBA. You
issue this CREATE TABLE statement.
Which statement is true?
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Sales identification values could be either numbers or characters,
or a combination of both.
All employee identification values are only 6 digits so the columnshould be variable in length.
Description values can range from 0 to 30 characters so the columnshould be fixed in length.
Today's date will be used if no value is provided for the sale date. (*)
7. Which statement about data types is true?
The BFILE data type stores character data up to four gigabytes in
the database.
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. (*)
8. 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
9. Which data types stores variable-length character data?
Select two.
(Choose all correct answers)
CHAR
NCHAR
CLOB (*)
VARCHAR2 (*)
10. You are designing a table for the Human Resourcesdepartment. This table must include a column that
contains each employee's hire date. Which data type should you specify for this column?
(1) Points
CHAR
DATE (*)
TIMESTAMP
INTERVAL YEAR TO MONTH
Section 8 Lesson 2
11. You need to store the SEASONAL data in months and years.
Which data type should you use?
DATE
TIMESTAMP
INTERVAL YEAR TO MONTH (*)
INTERVAL DAY TO SECOND
12. You are designing a table for the Sales department. Youneed to include a column that contains each sales
total. Which data typeshould you specify for this column?
CHAR
DATE
NUMBER (*)
VARCHAR2
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 3
13. 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?
DROP TABLE (*)
TRUNCATE TABLE
ALTER TABLE
DELETE TABLE
14. To do a logical delete of a column without the performance penalty of rewriting all the table datablocks you
can issuethe following command:
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
15. Which statement about decreasing the width of a column is true?
When a character column contains data, you cannot decrease the
width of the column.
When a character column contains data, you can decrease the width of the column without any restrictions.
When a character column contains data, you can decrease the width of the column if the existing data does
not violate the new size. (*)
You cannot decrease the width of a character column unless the
table in which the column resides is empty.
Section 8 Lesson 3
21. 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 to35 if the column currently
contains 200 records?
ALTER employee TABLE ALTER COLUMN (last_name VARCHAR2(35));
ALTER TABLE employee RENAME last_name VARCHAR2(35);
ALTER TABLE employee MODIFY (last_name VARCHAR2(35)); (*)
You CANNOT increase the width of the LAST_NAME column.
22. You need to remove all the rows from the SALES_HIST
table. You want to release the storage space, but do not want to removethe table structure. Which statement
should you use? Mark for Review
(1) Points
the DROP TABLE statement
the ALTER TABLE statement
the DELETE statement
the TRUNCATE TABLE statement (*)
You must drop and recreate the DONATIONS table to achieve theseresults.
You must use the ADD OR REPLACE option to achieve these results.
Section 9 Lesson 1
24. Which two statements about NOT NULL constraints are
true? (Choose two) Mark 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 beunique.
Columns without the NOT NULL constraint can contain null values bydefault.
You CANNOT add a NOT NULL constraint to an existing column usingthe ALTER TABLE ADD CONSTRAINT
statement. (*)
25. You need to ensure that the LAST_NAME column onlycontains certain character values. No numbers or
special characters areallowed.
Which type of constraint should you define on the LAST_NAME column? Mark
for Review
(1) Points
CHECK (*)
UNIQUE
NOT NULL
PRIMARY KEY
26. Which statement about constraints is true? Mark for
Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Column (*)
Section 9 Lesson 2
30. When creating the EMPLOYEES table, which clause couldyou 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)
Section 9 Lesson 2
31. Evaluate this CREATE TABLE statement:
1. CREATE TABLE part(
2. part_id NUMBER,
3. part_name VARCHAR2(25),
4. manufacturer_id NUMBER(9),
5. cost NUMBER(7,2),
6. retail_price NUMBER(7,2) NOT NULL,
7. CONSTRAINT part_id_pk PRIMARY KEY(part_id),
8. CONSTRAINT cost_nn NOT NULL(cost),
9. CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCESmanufacturer(id));
Which line will cause an error?
6
7
8 (*)
9
34. You need to create the PROJECT_HIST table. The table must meet these requirements:
1. The table must contain the EMPLOYEE_ID and TASKED_HOURS columns for
numeric data.
2. The table must contain the START_DATE and END_DATE column for date
values.
3. The table must contain the HOURLY_RATE and PROJECT_COST columns for
numeric data with precision and scale of 5,2 and 10,2 respectively.
4. The table must have a composite primary key on the EMPLOYEE_ID and START_DATE columns.
Evaluate this CREATE TABLE statement:
CREATE TABLE project_hist
( employee_id NUMBER,
start_date DATE,
end_date DATE,
tasked_hours NUMBER,
hourly_rate NUMBER(5,2),
project_cost NUMBER(10,2),
CONSTRAINT project_hist_pk PRIMARY KEY(employee_id, start_date));
How many of the requirements does the CREATE TABLE statement satisfy?
None of the four requirements
All four of the requirements (*)
Only three of the requirements
Only two of the requirements
35. 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.
36. 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 on the Parent table.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.
37. You need to create a composite primary key constraint on the EMPLOYEE table. Which statement is true?
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.
Section 9 Lesson 3
38. When dropping a constraint, which keyword(s) specifiesthat all the referential integrity constraints that
refer to the primaryand unique keys defined on the dropped columns are dropped as well? Mark
for Review
(1) Points
FOREIGN KEY
REFERENCES
CASCADE (*)
ON DELETE SET NULL
Section 9 Lesson 3
41. 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 (*)
ENABLE
SUPPLIER
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
Evaluate this statement:
44. You need to display the names and definitions of constraints only in your schema. Which data dictionary
view should you query? Mark for Review
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
45. The DEPARTMENTS table contains these columns:
DEPARTMENT_ID NUMBER, Primary Key
DEPARTMENT_ABBR VARCHAR2(4)
DEPARTMENT_NAME VARCHAR2(30)
MANAGER_ID NUMBER
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
The ALTER TABLE statement fails because the ADD CONSTRAINT clause
contains a syntax error. (*)
The ALTER TABLE statement succeeds, but does NOT recreate areferential constraint.
46. 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 employeesADD FOREIGN KEY CONSTRAINT dept_id_fk ON (department_id)
REFERENCESdepartments(department_id);
ALTER TABLE employeesADD FOREIGN KEY departments(department_id) REFERENCES (department_id);
Section 10 Lesson 1
48. Which of the following keywords cannot be used when creating a view? Mark for Review
(1) Points
HAVING
WHERE
ORDER BY
They are all valid keywords when creating views. (*)
49. You need to create a view that when queried will displaythe name, employee identification number, first
and last name, salary,
and department identification number. When queried, the display should besorted by salary from lowest to
highest, then by last name and first namealphabetically. The view definition should be created regardless of
theexistence of the EMPLOYEES table. No DML may be performed when using thisview. Evaluate these
statements:
CREATE OR REPLACE NOFORCE VIEW EMP_SALARY_V
AS SELECT employee_id, last_name, first_name, salary, department_idFROM employees WITH READ
ONLY;
SELECT *
FROM emp_salary_v
ORDER BY salary, last_name, first_name;
Section 10 Lesson 1
51. The FACULTY table contains these columns:
FACULTYID VARCHAR2(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
STATUS VARCHAR2(2) NOT NULL
You have been asked to compile a report that identifies all adjunct professors who will be teaching classes in
the upcoming term. You want to create a view that will simplify the creation of this report. Which
CREATE VIEW statements will accomplish this task?
CREATE VIEW
(SELECT first_name, last_name, status, courseid, subject, termFROM faculty, course WHERE facultyid =
facultyid);
CREATE VIEW pt_view ON(SELECT first_name, last_name, status, courseid, subject, term FROM faculty f
and course cWHERE f.facultyid = c.facultyid);
CREATE VIEW pt_view IN
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty course);
CREATE VIEW pt_view AS(SELECT first_name, last_name, status, courseid, subject, termFROM faculty f,
course cWHERE f.facultyid = c.facultyid);
(*)
52. Which of the following statements is a valid reason for using a view? Mark for Review
(1) Points
Views allow access to the data because the view displays all of thecolumns from the table.
Views provide data independence for infrequent users and application programs. One view can be used to
retrieve data from several tables. Views can be used to provide data security. (*)
Views are used when you only want to restrict DML operations using a WITH CHECK OPTION.
Views are not valid unless you have more than one user.
53. Which option would you use to modify a view rather than dropping it and recreating it?
FORCE
NOFORCE
CREATE OR REPLACE (*)
WITH ADMIN OPTION
54. Evaluate this CREATE VIEW statement:
CREATE VIEW emp_view
AS SELECT SUM(salary) FROM employees;
Which statement is true?
You cannot update data in the EMPLOYEES table using the EMP_VIEWview. (*)
You can update any data in the EMPLOYEES table using the EMP_VIEWview.
You can delete records from the EMPLOYEES table using the EMP_VIEWview.
You can update only the SALARY column in the EMPLOYEES table usingthe EMP_VIEW view.
55. In order to query a database using a view, which of thefollowing statements applies?
Use special VIEWSELECT Keyword
You can retrieve data from a view as you would from any table. (*)
You can never see all the rows in the table through the view.
The tables you are selecting from can be empty, yet the view still
returns the original data from those tables.
Section 10 Lesson 2
56. You cannot modify data in a view if the view contains
______.
the DISTINCT keyword (*)
a WHERE clause
a subquery in the FROM clause
the WITH CHECK OPTION clause
57. Which statement about performing DML operations on a view is true?
You can delete data in a view if the view contains the DISTINCT
keyword.
You cannot modify data in a view if the view contains a WHERE clause.
You cannot modify data in a view if the view contains a group function. (*)
You can modify data in a view if the view contains a GROUP BY clause.
58. Which statement about performing DML operations on a view is true?
You can perform DML operations on simple views. (*)
You cannot perform DML operations on a view that contains the WITH
CHECK OPTION clause.
You can perform DML operations on a view that contains the WITHREAD ONLY option.
You can perform DML operations on a view that contains columns defined by expressions, such as COST + 1.
59. What is the purpose of including the WITH CHECK OPTION clause when creating a view?
To make sure that the parent table(s) actually exist
To keep views from being queried by unauthorized persons
To make sure that data is not duplicated in the view
To make sure no rows are updated through the view that will hinder
those rows from being returned by the view. (*)
60. Which of the following is TRUE regarding simple views?
They derive data from many tables, so they typically contain joins.
They contain functions or groups of data
They can perform DML operations through the view (*)
They are not stored in the Data Dictionary
Section 10 Lesson 2
61. Your manager has just asked you to create a report that illustrates the salary range of all the employees at
your company. Which of the following SQL statements will create a view called SALARY_VU based
on the employee last names, department names, salaries, and salary gradesfor all employees? Use the
EMPLOYEES, DEPARTMENTS, and JOB_GRADES tables.
Label the columns Employee, Department, Salary, and Grade, respectively.
CREATE OR REPLACE VIEW salary_vu AS SELECT e.last_name "Employee", d.department_name
"Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees e, departments d, job_gradesWHERE e.department_id equals d.department_id AND
e.salary BETWEENj.lowest_sal and j.highest_sal;
CREATE OR REPLACE VIEW salary_vuAS SELECT e.empid "Employee", d.department_name
"Department", e.salary"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades jWHERE e.department_id = d.department_id NOT e.salary
BETWEEN j.lowest_saland j.highest_sal;
CREATE OR REPLACE VIEW salary_vuAS SELECT e.last_name "Employee", d.department_name
"Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades jWHERE e.department_id = d.department_id AND e.salary
BETWEEN j.lowest_saland j.highest_sal;
(*)
Section 11 Lesson 2
68. You need to retrieve the next available value for the
SALES_IDX sequence. Which would you include in your SQL statement? Mark
for Review
(1) Points
sales_idx
sales_idx.NEXT
sales_idx.NEXTVAL (*)
sales_idx.CURRVAL
69. Sequences can be used to: (choose three)
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist(*)
Generate a range of numbers and optionally cycle through them again
(*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
70. Which statement would you use to modify the EMP_ID_SEQ
sequence used to populate the EMPLOYEE_ID column in the EMPLOYEES table?
ALTER SEQUENCE emp_id_seq.employee_id ;
CREATE SEQUENCE emp_id_seq ;
ALTER TABLE employees ;
ALTER SEQUENCE emp_id_seq ; (*)
Section 11 Lesson 2
71. A gap can occur in a sequence because a user generated anumber from the sequence and then rolled
back the transaction. True or False?
True (*)
False
72. When used in a CREATE SEQUENCE statement, which keyword
specifies that a range of sequence values will be preloaded into memory?
LOAD
MEMORY
CACHE (*)
NOCACHE
NOCYCLE
Section 11 Lesson 3
73. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
It allows only the user CHAN to access TESTING using the synonym.
It eliminates the need for all users to qualify TESTING with its schema. (*)
74. Unique indexes are automatically created on columns that have which two types of constraints? Mark for
Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
75. Evaluate this statement:
CREATE INDEX sales_idx ON oe.sales (status);
Which statement is true?
Mark for Review
(1) Points
The CREATE INDEX creates a function-based index.
The CREATE INDEX statement creates a nonunique index. (*)
The CREATE INDEX statement creates a unique index.
The CREATE INDEX statement fails because of a syntax error.
Incorrect Incorrect. Refer to Section 11
76. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NOT NULL, Primary Key
SOCIAL_SECURITY_NUMBER NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER Foreign Key to DEPARTMENT_ID column of the
DEPARTMENTS table
SALARY NUMBER(8,2)
A synonym.
An index, either a normal or a function_based index. (*)
A composite index.
Nothing; the performance of this statement cannot be improved.
79. When creating an index on a table, which of the following statements are true? (Choose two)
(Choose all correct answers)
You should create an index if the table is large and most queries are expected to retrieve less than 2 to 4
percent of the rows. (*)
You should always create an index on tables that are frequently updated.
You should create an index if one or more columns are frequentlyused together in a join condition. (*)
You should create an index if the table is very small.
Correct Correct
80. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary KeyLAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTtable
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEEStable?
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Section 11 Lesson 3
You want to create an index named ADDRESS_INDEX on the CITY and STATE
columns of the CLIENTS table. You issue this statement:
85. For which column would you create an index? Mark for
Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Section 12 Lesson 2
86. User ADAM has successfully logged on to the database inthe past, but today he receives an error
message stating that (althoughhe has entered his password correctly) he cannot log on. What is the
mostlikely cause of the problem? Mark for Review
(1) Points
One or more object privileges have been REVOKED from Adam.
ADAM's CREATE SESSION privilege has been revoked. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
89. User Kate wants to create indexes on tables in her schema. What privilege must be granted to Kate so
that she can do this?
CREATE INDEX
CREATE ANY INDEX
ALTER TABLE
None; users do not need extra privileges to create indexes on tables in their own schema (*)
90. Which of the following are object privileges? (Choosetwo) Mark for Review
(1) Points
(Choose all correct answers)
SELECT (*)
DROP TABLE
CREATE TABLE
INSERT (*)
Section 12 Lesson 2
91. User JAMES has created a CUSTOMERS table and wants to
allow all other users to SELECT from it. Which command should JAMES use
to do this?Mark for Review
(1) Points
GRANT customers(SELECT) TO PUBLIC;
GRANT SELECT ON customers TO ALL;
GRANT SELECT ON customers TO PUBLIC; (*)
CREATE PUBLIC SYNONYM customers FOR james.customers;
92. Which of the following best describes a role in anOracle database? Mark for Review
(1) Points
A role is a type of system privilege.
A role is the part that a user plays in querying the database.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a
table.
Section 12 Lesson 3
93. Which of the following simplifies the administration of privileges?
an index
a view
a trigger
a role (*)
94. You need to grant user BOB SELECT privileges on the EMPLOYEES table. You want to allow BOB to
grant this privileges to otherusers. Which statement should you use? Mark for Review
(1) Points
GRANT SELECT ON employees TO bob WITH GRANT OPTION; (*)
GRANT SELECT ON employees TO PUBLIC WITH GRANT OPTION;
GRANT SELECT ON employees TO bob
GRANT SELECT ON employees TO bob WITH ADMIN OPTION;
95. User BOB's schema contains an EMPLOYEES table. BOB
executes the following statement:
GRANT SELECT ON employees TO mary WITH GRANT OPTION;
Which of the following statements can MARY now execute successfully?
(Choose two)
(Choose all correct answers)
SELECT FROM bob.employees; (*)
REVOKE SELECT ON bob.employees FROM bob;
GRANT SELECT ON bob.employees TO PUBLIC; (*)
DROP TABLE bob.employees;
96. When granting an object privilege, which option would you include to allow the grantee to grant the
privilege to another user?
WITH GRANT OPTION (*)
WITH ADMIN OPTION
PUBLIC
FORCE
97. Which keyword would you use to grant an object privilege to all database users?
ADMIN
ALL
PUBLIC (*)
USERS
98. Which data dictionary view shows which system privileges have been granted to a user?
USER_TAB_PRIVS
USER_SYS_PRIVS (*)
USER_SYSTEM_PRIVS
USER_SYSTEM_PRIVILEGES
Section 14 Lesson 1
99. Table MYTAB contains only one column of datatypeCHAR(1). A user executes the following statements in
the order shown.
INSERT INTO mytab VALUES ('A');
INSERT INTO mytab VALUES ('B');
COMMIT;
INSERT INTO mytab VALUES ('C');
ROLLBACK;
Which rows does the table now contain?
A, B and C
A and B (*)
C
None of the above
100. If a database crashes, all uncommitted changes areautomatically rolled back. True or False?
True (*)
False
Section 8 Lesson 1
1. You are creating the EMPLOYEES table. This table should contain the COMMISSION_PCT column and
use a value of 10 percent if no commission value is provided when a record is inserted. Which line should you
include in the CREATE TABLE statement to accomplish this task?
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)
2. Evaluate this CREATE TABLE statement:
CREATE TABLE line_item ( line_item_id NUMBER(9), order_id NUMBER(9),
product_id NUMBER(9));
You are a member of the SYSDBA role, but are not logged in as SYSDBA. You
issue this CREATE TABLE statement.
Which statement is true?
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
Today's date will be used if no value is provided for the sale date. (*)
7. Which statement about data types is true?
The BFILE data type stores character data up to four gigabytes in
the database.
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. (*)
8. 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
Incorrect Incorrect. Refer to Section 8
9.
Select two.
Which data types stores variable-length character data?
Mark for Review
(1) Points
(Choose all correct answers)
CHAR
NCHAR
CLOB (*)
VARCHAR2 (*)
10. You are designing a table for the Human Resourcesdepartment. This table must include a column that
contains each
employee's hire date. Which data type should you specify for this column?
Mark for Review
(1) Points
CHAR
DATE (*)
TIMESTAMP
INTERVAL YEAR TO MONTH
Section 8 Lesson 2
11. 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
Incorrect Incorrect. Refer to Section 8
12. You are designing a table for the Sales department. Youneed to include a column that contains each sales
total. Which data typeshould you specify for this column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Section 8 Lesson 3
13. 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
14. To do a logical delete of a column without the performance penalty of rewriting all the table data blocks
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'
15. Which statement about decreasing the width of a columnis true? Mark for Review
(1) Points
When a character column contains data, you cannot decrease thewidth of the column.
When a character column contains data, you can decrease the widthof the column without any restrictions.
When a character column contains data, you can decrease the width of the column if the existing data does
not violate the new size. (*)
You cannot decrease the width of a character column unless the
table in which the column resides is empty.
Section 8 Lesson 3
21. 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 to35 if the column currently
contains 200 records?
ALTER employee TABLE ALTER COLUMN (last_name VARCHAR2(35));
Section 9 Lesson 1
24. Which two statements about NOT NULL constraints are
true? (Choose two) Mark 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 TABLE ADD
CONSTRAINT statement. (*)
25. 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
26. Which statement about constraints is true? Mark for
Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Table (*)
Row
Dictionary
Column (*)
Section 9 Lesson 2
30. When creating the EMPLOYEES table, which clause couldyou 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)
31. Evaluate this CREATE TABLE statement:
1. CREATE TABLE part(
2. part_id NUMBER,
3. part_name VARCHAR2(25),
4. manufacturer_id NUMBER(9),
5. cost NUMBER(7,2),
6. retail_price NUMBER(7,2) NOT NULL,
7. CONSTRAINT part_id_pk PRIMARY KEY(part_id),
8. CONSTRAINT cost_nn NOT NULL(cost),
9. CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCESmanufacturer(id));
Which line will cause an error?
6
7
8 (*)
9
32. What is an attribute of data that is entered into a primary key column?
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 same datatype in another table.
Data that is entered into a primary key column is restricted to arange of numbers that is defined by the local
Oracle database.
33. Which of the following FOREIGN KEY Constraint keywords identifies the table and column in the parent
table? Mark for Review
(1) Points
RESEMBLES
ON DELETE CASCADE
REFERENTIAL
REFERENCES (*)
34. You need to create the PROJECT_HIST table. The table
must meet these requirements:
1. The table must contain the EMPLOYEE_ID and TASKED_HOURS columns for
numeric data.
2. The table must contain the START_DATE and END_DATE column for date
values.
3. The table must contain the HOURLY_RATE and PROJECT_COST columns for
numeric data with precision and scale of 5,2 and 10,2 respectively.
4. The table must have a composite primary key on the EMPLOYEE_ID and START_DATE columns.
Evaluate this CREATE TABLE statement:
CREATE TABLE project_hist
( employee_id NUMBER,
start_date DATE,
end_date DATE,
tasked_hours NUMBER,
hourly_rate NUMBER(5,2),
project_cost NUMBER(10,2),
CONSTRAINT project_hist_pk PRIMARY KEY(employee_id, start_date));
How many of the requirements does the CREATE TABLE statement satisfy?
None of the four requirements
All four of the requirements (*)
Only three of the requirements
Only two of the requirements
35. Which of the following best describes the function of aCHECK 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 beentered in a column or combination of
columns.
A CHECK constraint is created automatically when a PRIMARY KEYconstraint is created.
36. 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 on the Parent table.exist in the primarykey 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.
37. You need to create a composite primary key constraint onthe EMPLOYEE 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.
Section 9 Lesson 3
38. When dropping a constraint, which keyword(s) specifiesthat all the referential integrity constraints that
refer to the primaryand unique keys defined on the dropped columns are dropped as well? Mark
for Review
(1) Points
FOREIGN KEY
REFERENCES
CASCADE (*)
ON DELETE SET NULL
39. 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;
40. This SQL command will do what?
ALTER TABLE employeesADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id)
REFERENCESemployees(employee_id);
Alter the table employees and disable the emp_manager_fkconstraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating thata manager must already be an
employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restrictingmanager ID to match every employee
ID.
Alter table employees and add a FOREIGN KEY constraint thatindicates each employee ID must be unique.
Section 9 Lesson 3
41. 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 (*)
ENABLE
SUPPLIER
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
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
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 constraint.
Incorrect Incorrect. Refer to Section 9
46. Which statement should you use to add a FOREIGN KEYconstraint 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 employeesMODIFY COLUMN dept_id_fk FOREIGN KEY (department_id)
REFERENCESdepartments(department_id);
ALTER TABLE employeesADD CONSTRAINT dept_id_fk FOREIGN KEY (department_id)
REFERENCESdepartments(department_id);
(*)
ALTER TABLE employeesADD FOREIGN KEY CONSTRAINT dept_id_fk ON (department_id)
REFERENCESdepartments(department_id);
ALTER TABLE employeesADD FOREIGN KEY departments(department_id) REFERENCES (department_id);
SELECT *
FROM emp_salary_v
ORDER BY salary, last_name, first_name;
50. Which keyword(s) would you include in a CREATE VIEW statement to create the view regardless of
whether or not the base table exists?
FORCE (*)
NOFORCE
OR REPLACE
Section 10 Lesson 1
51. The FACULTY table contains these columns:
FACULTYID VARCHAR2(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
STATUS VARCHAR2(2) NOT NULL
You have been asked to compile a report that identifies all adjunct professors who will be teaching classes in
the upcoming term. You want to
create a view that will simplify the creation of this report. Which
CREATE VIEW
(SELECT first_name, last_name, status, courseid, subject, term FROM faculty, course WHERE facultyid =
facultyid);
CREATE VIEW pt_view ON(SELECT first_name, last_name, status, courseid, subject, term FROM faculty f
and course c
CREATE VIEW pt_view AS(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course cWHERE f.facultyid = c.facultyid);
(*)
52. Which of the following statements is a valid reason for using a view? Mark for Review
(1) Points
Views allow access to the data because the view displays all of the columns from the table.
Views provide data independence for infrequent users and application programs. One view can be used to
retrieve data from severaltables. Views can be used to provide data security. (*)
Views are used when you only want to restrict DML operations using a WITH CHECK OPTION.
Views are not valid unless you have more than one user.
53. Which option would you use to modify a view rather than dropping it and recreating it?
FORCE
NOFORCE
CREATE OR REPLACE (*)
WITH ADMIN OPTION
You can modify data in a view if the view contains a GROUP BYclause.
59. What is the purpose of including the WITH CHECK OPTIONclause when creating a view? Mark for
Review
(1) Points
To make sure that the parent table(s) actually exist
To keep views from being queried by unauthorized persons
To make sure that data is not duplicated in the view
To make sure no rows are updated through the view that will hinderthose rows from being returned by the
view. (*)
Section 10 Lesson 2
61. Your manager has just asked you to create a report thatillustrates the salary range of all the employees at
your company. Whichof the following SQL statements will create a view called SALARY_VU basedon the
employee last names, department names, salaries, and salary gradesfor all employees? Use the
EMPLOYEES, DEPARTMENTS, and JOB_GRADES tables.
Label the columns Employee, Department, Salary, and Grade, respectively.
CREATE OR REPLACE VIEW salary_vuAS SELECT e.last_name "Employee", d.department_name
"Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees e, departments d, job_gradesWHERE e.department_id equals d.department_id AND
e.salary BETWEENj.lowest_sal and j.highest_sal;
CREATE OR REPLACE VIEW salary_vuAS SELECT e.empid "Employee", d.department_name
"Department", e.salary"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades jWHERE e.department_id = d.department_id NOT e.salary
BETWEEN j.lowest_saland j.highest_sal;
62. You can create a view if the view subquery contains an inline view. True or False?
True (*)
False
Section 10 Lesson 3
63. Which statement about an inline view is true? Mark
for Review
(1) Points
An inline view is a schema object.
An inline view is a subquery in the FROM clause, often named withan alias. (*)
Section 11 Lesson 2
71. A gap can occur in a sequence because a user generated anumber from the sequence and then rolled
back the transaction. True or
False? Mark for Review
(1) Points
True (*)
False
NOCACHE
NOCYCLE
Section 11 Lesson 3
73. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
It allows only the user CHAN to access TESTING using the synonym.
It eliminates the need for all users to qualify TESTING with its
schema. (*)
74. Unique indexes are automatically created on columns thathave which two types of constraints? Mark for
Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
75. Evaluate this statement:
CREATE INDEX sales_idx ON oe.sales (status);
Which statement is true?
The CREATE INDEX creates a function-based index.
The CREATE INDEX statement creates a nonunique index. (*)
The CREATE INDEX statement creates a unique index.
The CREATE INDEX statement fails because of a syntax error.
78. What would you create to make the following statementexecute faster?
SELECT *
FROM employees
WHERE LOWER(last_name) = 'chang';
A synonym.
An index, either a normal or a function_based index. (*)
A composite index.
Nothing; the performance of this statement cannot be improved.
79. When creating an index on a table, which of thefollowing statements are true? (Choose two) Mark for
Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queriesare expected to retrieve less than 2 to 4
percent of the rows. (*)
You should always create an index on tables that are frequentlyupdated.
You should create an index if one or more columns are frequentlyused together in a join condition. (*)
You should create an index if the table is very small.
Section 11 Lesson 3
81. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE
columns of the CLIENTS table. You issue this statement:
82. You want to create a composite index on the FIRST_NAMEand LAST_NAME columns of the
EMPLOYEES table. Which SQL statement willaccomplish this task? Mark for Review
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
85. For which column would you create an index? Mark for
Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Section 12 Lesson 2
86. User ADAM has successfully logged on to the database inthe past, but today he receives an error
message stating that (althoughhe has entered his password correctly) he cannot log on. What is the
mostlikely cause of the problem? Mark for Review
(1) Points
One or more object privileges have been REVOKED from Adam.
ADAM's CREATE SESSION privilege has been revoked. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Incorrect Incorrect. Refer to Section 12
87. User SUSAN creates an EMPLOYEES table, and then createsa view EMP_VIEW which shows only the
FIRST_NAME and LAST_NAME columns ofEMPLOYEES. User RUDI needs to be able to access employees'
names but noother data from EMPLOYEES. Which statement should SUSAN execute to allow
this? Mark for Review
(1) Points
SELECT * FROM emp_view FOR rudi;
CREATE SYNONYM emp_view FOR employees;
GRANT SELECT ON emp_view TO rudi; (*)
GRANT SELECT ON emp_view ONLY TO rudi;
88. Which of the following are system privileges? (Choosetwo) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE SYNONYM (*)
INDEX
90. Which of the following are object privileges? (Choosetwo) Mark for Review
(1) Points
(Choose all correct answers)
SELECT (*)
DROP TABLE
CREATE TABLE
INSERT (*)
Section 12 Lesson 2
91. User JAMES has created a CUSTOMERS table and wants to
allow all other users to SELECT from it. Which command should JAMES use
to do this?Mark for Review
(1) Points
GRANT customers(SELECT) TO PUBLIC;
GRANT SELECT ON customers TO ALL;
GRANT SELECT ON customers TO PUBLIC; (*)
CREATE PUBLIC SYNONYM customers FOR james.customers;
92. Which of the following best describes a role in anOracle database? Mark for Review
(1) Points
A role is a type of system privilege.
A role is the part that a user plays in querying the database.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a
table.
Section 12 Lesson 3
Section 14 Lesson 1
99. Table MYTAB contains only one column of datatypeCHAR(1). A user executes the following statements in
the order shown.
INSERT INTO mytab VALUES ('A');
INSERT INTO mytab VALUES ('B');
COMMIT;
INSERT INTO mytab VALUES ('C');
ROLLBACK;
A and B (*)
C
None of the above
100. If a database crashes, all uncommitted changes areautomatically rolled back. True or False? Mark for
Review
(1) Points
True (*)
False