SQL Multiple Choice Questions Fundamentals I

Oracle Database 10g SQL Fundamentals I

 

Chapter07: Using the Set Operators & Chapter 08: Manipulating Data

Question: 1

View the Exhibit and examine the structure of the EMPLOYEES and DEPARTMENTS tables.

 

Which SET operator would you use in the blank space in the following SQL statement to list the departments where all the employees have managers?

 

 

SELECT department_id

FROM departments

____

SELECT department_id

FROM employees

WHERE manager_id IS NULL;

 

A. UNION B. MINUS

C. INTERSECT D. UNION ALL

 

Answer: B

 

Question: 2

View the Exhibit and examine the structure of the LOCATIONS and DEPARTMENTS tables.

 

Which SET operator should be used in the blank space in the following SQL statement to display the cities that have departments located in them?

SELECT location_id, city

FROM locations

 

SELECT location_id, city

FROM locations JOIN departments

USING(location_id);

 

A. UNION

B. MINUS

C. INTERSECT

D. UNION ALL

 

Answer: C

 

Question: 3

 

 

View the Exhibit and examine the data in the EMPLOYEES tables.

 

Evaluate the following SQL statement: SELECT employee_id, department_id FROM employees

WHERE department_id= 50 ORDER BY department_id

UNION

SELECT employee_id, department_id

FROM employees

WHERE department_id= 90

UNION

SELECT employee_id, department_id

FROM employees

WHERE department_id= 10;

What would be the outcome of the above SQL statement?

 

A. The statement would execute successfully and display all the rows in the ascending order of

DEPARTMENT_ID.

B. The statement would execute successfully but it will ignore the ORDER BY clause and display the rows in random order.

C. The statement would not execute because the positional notation instead of the column name should be used with the ORDER BY clause.

D. The statement would not execute because the ORDER BY clause should appear only at the end of the SQL statement, that is, in the last SELECT statement.

 

Answer: D

 

Question: 4

View the Exhibit and examine the structure of the EMPLOYEES and JOB_HISTORY tables.

 

The query should display the employee IDs of all the employees who have held the job SA_MAN

at any time during their tenure.

Choose the correct SET operator to fill in the blank space and complete the following query. SELECT employee_id

FROM employees

WHERE job_id = ‘SA_MAN’

____________ SELECT employee_id FROM job_history

WHERE job_id=’SA_MAN’;

 

A. UNION

B. MINUS

C. INTERSECT

D. UNION ALL

 

Answer: A

 

Question: 5

Evaluate the following SQL statement: SELECT 2 col1,’y’ col2

FROM dual UNION SELECT 1,’x’ FROM dual UNION

SELECT 3,NULL

 

FROM dual

ORDER BY 2;

Which statement is true regarding the output of the SQL statement?

 

A. It would execute and the order of the values in the first column would be 3, 2, 1. B. It would execute and the order of the values in the first column would be 1, 2, 3.

C. It would not execute because the column alias name has not been used in the ORDER BY

clause.

D. It would not execute because the number 2 in the ORDER BY clause would conflict with the value 2 in the first SELECT statement.

 

Answer: B

 

Question: 6

View the Exhibit and examine the structure of the CUST table.

 

 

 

 

Evaluate the following SQL statements executed in the given order: ALTER TABLE cust

ADD CONSTRAINT cust_id_pk PRIMARY KEY(cust_id) DEFERRABLE INITIALLY DEFERRED; INSERT INTO cust VALUES (1,’RAJ’); –row 1

INSERT INTO cust VALUES (1,’SAM’); –row 2

COMMIT;

SET CONSTRAINT cust_id_pk IMMEDIATE; INSERT INTO cust VALUES (1,’LATA’); –row 3

INSERT INTO cust VALUES (2,’KING’); –row 4

COMMIT;

Which rows would be made permanent in the CUST table?

 

A. row 4 only

B. rows 2 and 4

C. rows 3 and 4

D. rows 1 and 4

 

Answer: C

 

Question: 7

 

Given below are the SQL statements executed in a user session:

 

CREATE TABLE product

(pcode NUMBER(2), pname VARCHAR2(10));

INSERT INTO product VALUES(1, ‘pen’); INSERT INTO product VALUES (2,’pencil’); SAVEPOINT a;

UPDATE product SET pcode = 10 WHERE pcode = 1; SAVEPOINT b;

DELETE FROM product WHERE pcode = 2; COMMIT;

DELETE FROM product WHERE pcode=10; ROLLBACK TO SAVEPOINT a;

 

Which statement describes the consequences?

 

A. No SQL statement would be rolled back.

B. Both the DELETE statements would be rolled back.

C. Only the second DELETE statement would be rolled back.

D. Both the DELETE statements and the UPDATE statement would be rolled back.

 

Answer: A

 

Question: 8

View the Exhibit and examine the structure of the ORDERS table.

 

 

 

The ORDERS table belongs to the user OE. HR is another user in the database. Evaluate the commands issued by users OE and HR in the following order: Statement 1 by user OE: GRANT SELECT,

UPDATE(customer_id, order_total) ON orders

TO hr;

Statement 1 by user HR: SELECT * FROM oe.orders; Statement 2 by user HR: UPDATE oe.orders

SET order_total= 10000;

Which statement is true regarding the above commands?

 

A. Statement 1 by user OE would not work because the statement has to be issued by the DBA. B. Statement 2 by user HR would not work because the grant is only for SELECT in a subquery

of update.

C. There are no errors in the statements issued by OE and HR; all the statements would execute successfully.

D. Statement 1 by user HR would not work because SELECT and UPDATE privileges have been granted only on CUSTOMER_ID and ORDER_TOTAL columns.

 

Answer: C

 

Question: 9

View the Exhibit and examine the structure of the ORDERS table.

 

NEW_ORDERS is a new table with the columns ORD_ID, ORD_DATE, CUST_ID, and ORD_TOTAL that have the same data types and size as the corresponding columns in the ORDERS table.

Evaluate the following INSERT statement:

INSERT INTO new_orders (ord_id, ord_date, cust_id, ord_total) VALUES(SELECT order_id,order_date,customer_id,order_total FROM orders

WHERE order_date > ’31-dec-1999′); Why would the INSERT statement fail?

 

A. because column names in NEW_ORDERS and ORDERS tables do not match

B. because the VALUES clause cannot be used in an INSERT with a subquery

C. because the WHERE clause cannot be used in a subquery embedded in an INSERT

statement

D. because the total number of columns in the NEW_ORDERS table does not match the total number of columns in the ORDERS table

 

Answer: B

 

Question: 10

View the Exhibit and examine the structure of the ORDERS table.

 

Which UPDATE statement is valid?

 

A. UPDATE orders

SET order_date = ’12-mar-2007′, order_total IS NULL

WHERE order_id = 2455;

B. UPDATE orders

SET order_date = ’12-mar-2007′, order_total = NULL

WHERE order_id = 2455;

C. UPDATE orders

SET order_date = ’12-mar-2007′

AND order_total = TO_NUMBER(NULL) WHERE order_id = 2455;

D. UPDATE orders

SET order_date = TO_DATE(’12-mar-2007′,’dd-mon-yyyy’), SET order_total = TO_NUMBER(NULL)

WHERE order_id = 2455;

 

Answer: A

 

Question: 11

Which three statements indicate the end of a transaction? (Choose three.)

 

A. after a COMMIT is issued

B. after a ROLLBACK is issued

C. after a SAVEPOINT is issued

D. after a SELECT statement is issued

E. after a CREATE statement is issued

 

Answer: A, B, E

 

Question: 12

View the Exhibit and examine the descriptions of the DEPT and LOCATIONS tables.

 

You want to update the CITY column of the DEPT table for all the rows with the corresponding value in the CITY column of the LOCATIONS table for each department.

Which SQL statement would you execute to accomplish the task?

 

A. UPDATE dept d

SET city = ANY (SELECT city

FROM locations l); B. UPDATE dept d

SET city = (SELECT city

FROM locations l)

WHERE d.location_id = l.location_id; C. UPDATE dept d

SET city = (SELECT city

FROM locations l

WHERE d.location_id = l.location_id); D. UPDATE dept d

SET city = ALL (SELECT city

FROM locations l

WHERE d.location_id = l.location_id);

 

Answer: C

 

Question: 13

Evaluate the following DELETE statement: DELETE FROM orders;

There are no other uncommitted transactions on the ORDERS table. Which statement is true about the DELETE statement?

 

A. It removes all the rows in the table and allows ROLLBACK.

B. It would not remove the rows if the table has a primary key.

C. It removes all the rows as well as the structure of the table.

D. It removes all the rows in the table and does not allow ROLLBACK.

 

Answer: A

 

Question: 14

View the Exhibit and examine the structure of ORDERS and ORDER_ITEMS tables.

ORDER_ID is the primary key in the ORDERS table.

It is also the foreign key in the ORDER_ITEMS table wherein it is created with the ON DELETE CASCADE option.

Which DELETE statement would execute successfully?

 

A. DELETE order_id

FROM orders

WHERE order_total < 1000;

B. DELETE orders

WHERE order_total < 1000; C. DELETE

FROM orders

WHERE (SELECT order_id

FROM order_items);

D. DELETE orders o, order_items i

WHERE o.order_id = i.order_id;

 

Answer: B

 

Question: 15

View the Exhibit and examine the structure of EMPLOYEES and JOB_HISTORY tables.

 

The EMPLOYEES table maintains the most recent information regarding salary, department, and job for all the employees. The JOB_HISTORY table maintains the record for all the job changes for the employees. You want to delete all the records from the JOB_HISTORY table that are repeated in the EMPLOYEES table.

Which two SQL statements can you execute to accomplish the task? (Choose two.)

 

A. DELETE

FROM job_history j

WHERE employee_id =

(SELECT employee_id

FROM employees e

WHERE j.employee_id = e.employee_id) AND job_id = (SELECT job_id

FROM employees e

WHERE j.job_id = e.job_id);

B. DELETE

FROM job_history j

WHERE (employee_id, job_id) = ALL

(SELECT employee_id, job_

 

FROM employees e

WHERE j.employee_id = e.employee_id and j.job_id = e.job_id )

C. DELETE

FROM job_history j

WHERE employee_id =

(SELECT employee_id

FROM employees e

WHERE j.employee_id = e.employee_id and j.job_id = e.job_id )

D. DELETE

FROM job_history j

WHERE (employee_id, job_id) =

(SELECT employee_id, job_id

FROM employees e

WHERE j.employee_id = e.employee_id and j.job_id = e.job_id )

 

Answer: C, D

 

Question: 16

View the Exhibit and examine the structure of ORDERS and CUSTOMERS tables.

 

Evaluate the following UPDATE statement: UPDATE

(SELECT order_date, order_total, customer_id

FROM orders)

SET order_date = ’22-mar-2007′ WHERE customer_id =

(SELECT customer_id

FROM customers

WHERE cust_last_name = ‘Roberts’ AND

credit_limit = 600);

 

Which statement is true regarding the execution of the above UPDATE statement?

 

A. It would not execute because two tables cannot be used in a single UPDATE statement.

B. It would execute and restrict modifications to only the columns specified in the SELECT statement.

C. It would not execute because a subquery cannot be used in the WHERE clause of an UPDATE statement.

D. It would not execute because the SELECT statement cannot be used in place of the table name.

 

Answer: B

 

Question: 17

View the Exhibit and examine the structure of ORDERS and CUSTOMERS tables.

 

 

Which INSERT statement should be used to add a row into the ORDERS table for the customer whose CUST_LAST_NAME is Roberts and CREDIT_LIMIT is 600?

 

A. INSERT INTO orders

VALUES (1,’10-mar-2007′, ‘direct’,

(SELECT customer_id

FROM customers

WHERE cust_last_name=’Roberts’ AND

credit_limit=600), 1000);

B. INSERT INTO orders (order_id,order_date,order_mode,

(SELECT customer_id

FROM customers

WHERE cust_last_name=’Roberts’ AND

credit_limit=600),order_total)

VALUES(1,’10-mar-2007′, ‘direct’, &&customer_id, 1000); C. INSERT INTO orders (order_id,order_date,order_mode,

 

(SELECT customer_id

FROM customers

WHERE cust_last_name=’Roberts’ AND

credit_limit=600),order_total)

VALUES(1,’10-mar-2007′, ‘direct’, &customer_id, 1000);

D. INSERT INTO(SELECT o.order_id, o.order_date,o.order_mode,c.customer_id, o.order_total

FROM orders o, customers c

WHERE o.customer_id = c.customer_id

AND c.cust_last_name=’Roberts’ ANDc.credit_limit=600 ) VALUES (1,’10-mar-2007′, ‘direct’,(SELECT customer_id FROM customers

WHERE cust_last_name=’Roberts’ AND

credit_limit=600), 1000);

 

Answer: A

 

Question: 18

View the Exhibit and examine the data in EMPLOYEES and DEPARTMENTS tables.

 

 

 

In the EMPLOYEES table EMPLOYEE_ID is the PRIMARY KEY and DEPARTMENT_ID is the FOREIGN KEY. In the DEPARTMENTS table DEPARTMENT_ID is the PRIMARY KEY. Evaluate the following UPDATE statement:

UPDATE employees a

SET department_id =

(SELECT department_id

FROM departments

WHERE location_id = ‘2100’),

(salary, commission_pct) =

(SELECT 1.1*AVG(salary), 1.5*AVG(commission_pct) FROM employees b

WHERE a.department_id = b.department_id) WHERE first_name||’ ‘||last_name = ‘Amit Banda’; What would be the outcome of the above statement?

 

A. It would execute successfully and update the relevant data.

B. It would not execute successfully because there is no LOCATION_ID 2100 in the

DEPARTMENTS table.

C. It would not execute successfully because the condition specified with the concatenation operator is not valid.

D. It would not execute successfully because multiple columns

(SALARY,COMMISSION_PCT)cannot be used in an UPDATE statement.

 

Answer: A

 

Question: 19

You executed the following SQL statements in the given order: CREATE TABLE orders

(order_id NUMBER(3) PRIMARY KEY, order_date DATE,

customer_id number(3));

INSERT INTO orders VALUES (100,’10-mar-2007′,222); ALTER TABLE orders MODIFY order_date NOT NULL; UPDATE orders SET customer_id=333;

DELETE FROM order;

The DELETE statement results in the following error: ERROR at line 1:

ORA-00942: table or view does not exist

What would be the outcome?

 

A. All the statements before the DELETE statement would be rolled back.

B. All the statements before the DELETE statement would be implicitly committed within the session.

 

C. All the statements up to the ALTER TABLE statement would be committed and the outcome of

UPDATE statement would be rolled back.

D. All the statements up to the ALTER TABLE statement would be committed and the outcome of the UPDATE statement is retained uncommitted within the session.

 

Answer: D

 

Question: 20

View the Exhibit and examine the structure of ORDER_ITEMS and ORDERS tables.

 

You need to remove from the ORDER_ITEMS table those rows that have an order status of 0 or

1 in the ORDERS table.

Which DELETE statements are valid? (Choose all that apply.)

 

A. DELETE

FROM order_items

WHERE order_id IN (SELECT order_id

FROM orders

WHERE order_status in (0,1));

B. DELETE *

FROM order_items

WHERE order_id IN (SELECT order_id

FROM orders

WHERE order_status IN (0,1));

C. DELETE FROM order_items i

WHERE order_id = (SELECT order_id FROM orders o

WHERE i.order_id = o.order_id AND

order_status IN (0,1));

D. DELETE

FROM (SELECT * FROM order_items i,orders o

WHERE i.order_id = o.order_id AND order_status IN (0,1));

 

Answer: A, C, D

 

Chapter 09:Using DDL Statements to Create and Manage Tables & Chapter 10: Creating Other Schema Objects

Question: 1

Evaluate the CREATE TABLE statement: CREATE TABLE products

(product_id NUMBER(6) CONSTRAINT prod_id_pk PRIMARY KEY, product_name VARCHAR2(15));

Which statement is true regarding the PROD_ID_PK constraint?

 

A. It would be created only if a unique index is manually created first.

B. It would be created and would use an automatically created unique index.

C. It would be created and would use an automatically created no unique index.

D. It would be created and remains in a disabled state because no index is specified in the command.

 

Answer: B

 

Question: 2

Which CREATE TABLE statement is valid?

 

A. CREATE TABLE ord_details

(ord_no NUMBER(2) PRIMARY KEY, item_no NUMBER(3) PRIMARY KEY, ord_date date NOT NULL);

B. CREATE TABLE ord_details

(ord_no NUMBER(2) UNIQUE, NOT NULL, item_no NUMBER(3),

ord_date date DEFAULT SYSDATE NOT NULL); C. CREATE TABLE ord_details

(ord_no NUMBER(2) ,

item_no NUMBER(3),

ord_date date DEFAULT NOT NULL, CONSTRAINT ord_uq UNIQUE (ord_no), CONSTRAINT ord_pk PRIMARY KEY (ord_no));

D. CREATE TABLE ord_details

(ord_no NUMBER(2), item_no NUMBER(3),

ord_date date DEFAULT SYSDATE NOT NULL, CONSTRAINT ord_pk PRIMARY KEY (ord_no, item_no));

 

Answer: D

 

Question: 3

You need to create a table with the following column specifications:

 

1. Employee ID (numeric data type) for each employee

2. Employee Name, (character data type) which stores the employee name

3. Hire date, to store the date when the employee joined the organization

4. Status (character data type). It should contain the value if no data is entered.

5. Resume (character large object [CLOB] data type), which would contain the resume submitted by the employee

 

Which is the correct syntax to create this table?

 

A. CREATE TABLE EMP_1

(emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE,

e_status VARCHAR2(10) DEFAULT ‘ACTIVE’, resume CLOB(200));

B. CREATE TABLE 1_EMP

(emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE,

emp_status VARCHAR2(10) DEFAULT ‘ACTIVE’, resume CLOB);

C. CREATE TABLE 1_EMP

(emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE,

emp_status VARCHAR2(10) DEFAULT “ACTIVE”, resume CLOB);

D. CREATE TABLE EMP_1

(emp_id NUMBER, emp_name VARCHAR2(25), start_date DATE,

emp_status VARCHAR2(10) DEFAULT ‘ACTIVE’, resume CLOB);

 

Answer: D

 

Question: 4

View the Exhibit and examine the structure of the ORDERS table.

 

 

The ORDER_ID column is the PRIMARY KEY in the ORDERS table. Evaluate the following CREATE TABLE command:

CREATE TABLE new_orders(ord_id, ord_date DEFAULT SYSDATE, cust_id) AS SELECT order_id,order_date,customer_id

FROM orders;

Which statement is true regarding the above command?

 

A. The NEW_ORDERS table would not get created because the DEFAULT value cannot be specified in the column definition.

B. The NEW_ORDERS table would get created and only the NOT NULL constraint defined on the specified columns would be passed to the new table.

C. The NEW_ORDERS table would not get created because the column names in the CREATE TABLE command and the SELECT clause do not match.

D. The NEW_ORDERS table would get created and all the constraints defined on the specified columns in the ORDERS table would be passed to the new table.

 

Answer: B

 

Question: 5

Evaluate the following command: CREATE TABLE employees

(employee_id NUMBER(2) PRIMARY KEY, last_name VARCHAR2(25) NOT NULL, department_id NUMBER(2),

job_id VARCHAR2(8), salary NUMBER(10,2));

 

You issue the following command to create a view that displays the IDs and last names of the sales staff in the organization:

CREATE OR REPLACE VIEW sales_staff_vu AS SELECT employee_id, last_name,job_id

FROM employees

WHERE job_id LIKE ‘SA_%’ WITH CHECK OPTION;

Which statements are true regarding the above view? (Choose all that apply.)

 

A. It allows you to insert details of all new staff into the EMPLOYEES table.

B. It allows you to delete the details of the existing sales staff from the EMPLOYEES table. C. It allows you to update the job ids of the existing sales staff to any other job id in the

EMPLOYEES table.

D. It allows you to insert the IDs, last names and job ids of the sales staff from the view if it is used in multitable INSERT statements.

 

Answer: B, D

 

Question: 6

Evaluate the SQL statements: CREATE TABLE new_order

(orderno NUMBER(4),

booking_date TIMESTAMP WITH LOCAL TIME ZONE);

The database is located in San Francisco where the time zone is -8:00. The user is located in New York where the time zone is -5:00.

A New York user inserts the following record: INSERT INTO new_order

VALUES(1, TIMESTAMP ?007-05-10 6:00:00 -5:00?); Which statement is true?

 

A. When the New York user selects the row, booking_date is displayed as ‘007-05-10

3.00.00.000000’

B. When the New York user selects the row, booking_date is displayed as ‘2007-05-10

6.00.00.000000 -5:00’.

C. When the San Francisco user selects the row, booking_date is displayed as ‘007-05-10

3.00.00.000000’

D. When the San Francisco user selects the row, booking_date is displayed as ‘007-05-10

3.00.00.000000 -8:00’

 

Answer: C

 

Question: 7

Which two statements are true regarding constraints? (Choose two.)

 

A. A foreign key cannot contain NULL values.

B. A column with the UNIQUE constraint can contain NULL.

C. A constraint is enforced only for the INSERT operation on a table.

D. A constraint can be disabled even if the constraint column contains data.

E. All the constraints can be defined at the column level as well as the table level.

 

Answer: B, D

 

Question: 8

Which two statements are true? (Choose two.)

 

A. The USER_SYNONYMS view can provide information about private synonyms.

B. The user SYSTEM owns all the base tables and user-accessible views of the data dictionary. C. All the dynamic performance views prefixed with V$ are accessible to all the database users. D. The USER_OBJECTS view can provide information about the tables and views created by the

user only.

E. DICTIONARY is a view that contains the names of all the data dictionary views that the user can access.

 

Answer: A, E

 

Question: 9

Evaluate the following CREATE SEQUENCE statement: CREATE SEQUENCE seq1

START WITH 100

INCREMENT BY 10

MAXVALUE 200

CYCLE NOCACHE;

The sequence SEQ1 has generated numbers up to the maximum limit of 200. You issue the following SQL statement:

SELECT seq1.nextval FROM dual;

What is displayed by the SELECT statement?

 

A. 1

B. 10

C. 100

D. an error

Answer: A

 

Question: 10

EMPDET is an external table containing the columns EMPNO and ENAME. Which command would work in relation to the EMPDET table?

 

A. UPDATE empdet

SET ename = ‘Amit’ WHERE empno = 1234;

B. DELETE FROM empdet

WHERE ename LIKE ‘J%’;

C. CREATE VIEW empvu

AS

SELECT * FROM empdept;

D. CREATE INDEX empdet_idx

ON empdet(empno);

 

Answer: C

 

Question: 11

View the Exhibit and examine the data in ORDERS and ORDER_ITEMS tables.

 

 

You need to create a view that displays the ORDER ID, ORDER_DATE, and the total number of items in each order.

Which CREATE VIEW statement would create the view successfully?

 

A. CREATE OR REPLACE VIEW ord_vu (order_id,order_date) AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)

“NO OF ITEMS”

FROM orders o JOIN order_items i

ON (o.order_id = i.order_id)

GROUP BY o.order_id,o.order_date; B. CREATE OR REPLACE VIEW ord_vu

AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)

“NO OF ITEMS”

FROM orders o JOIN order_items i

ON (o.order_id = i.order_id)

GROUP BY o.order_id,o.order_date; C. CREATE OR REPLACE VIEW ord_vu

AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id) FROM orders o JOIN order_items i

ON (o.order_id = i.order_id)

GROUP BY o.order_id,o.order_date; D. CREATE OR REPLACE VIEW ord_vu

AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)||’ NO OF ITEMS’ FROM orders o JOIN order_items i

ON (o.order_id = i.order_id)

GROUP BY o.order_id,o.order_date

WITH CHECK OPTION;

 

Answer: B

 

Question: 12

You need to create a table for a banking application with the following considerations:

 

1) You want a column in the table to store the duration of the credit period.

2) The data in the column should be stored in a format such that it can be easily added and subtracted with

3) date type data without using the conversion functions.

4) The maximum period of the credit provision in the application is 30 days.

5) The interest has to be calculated for the number of days an individual has taken a credit for.

 

Which data type would you use for such a column in the table?

 

A. INTERVAL YEAR TO MONTH

B. INTERVAL DAY TO SECOND

C. TIMESTAMP WITH TIME ZONE

D. TIMESTAMP WITH LOCAL TIME ZONE

 

Answer: B

 

Question: 13

Which two statements are true regarding views? (Choose two.)

 

A. A simple view in which column aliases have been used cannot be updated.

B. A subquery used in a complex view definition cannot contain group functions or joins.

C. Rows cannot be deleted through a view if the view definition contains the DISTINCT keyword. D. Rows added through a view are deleted from the table automatically when the view is

dropped.

E. The OR REPLACE option is used to change the definition of an existing view without dropping and re-creating it.

F. The WITH CHECK OPTION constraint can be used in a view definition to restrict the columns displayed through the view.

 

Answer: C, E

 

Question: 14

Which two statements are true about sequences created in a single instance database? (Choose two.)

 

A. The numbers generated by a sequence can be used only for one table.

B. DELETE <sequencename> would remove a sequence from the database.

C. CURRVAL is used to refer to the last sequence number that has been generated.

D. When the MAXVALUE limit for a sequence is reached, you can increase the MAXVALUE limit by using the ALTER SEQUENCE statement.

E. When a database instance shuts down abnormally, the sequence numbers that have been cached but not used would be available once again when the database instance is restarted.

 

Answer: C, D

 

Question: 15

Which statements are correct regarding indexes? (Choose all that apply.)

 

A. When a table is dropped, the corresponding indexes are automatically dropped.

B. For each DML operation performed, the corresponding indexes are automatically updated.

C. Indexes should be created on columns that are frequently referenced as part of an expression.

D. A non-deferrable PRIMARY KEY or UNIQUE KEY constraint in a table automatically creates a

unique index.

 

Answer: A, B, D

 

Question: 16

The ORDERS table belongs to the user OE. OE has granted the SELECT privilege on the

ORDERS table to the user HR.

Which statement would create a synonym ORD so that HR can execute the following query successfully?

SELECT * FROM ord;

 

A. CREATE SYNONYM ord FOR orders; This command is issued by OE.

B. CREATE PUBLIC SYNONYM ord FOR orders; This command is issued by OE.

C. CREATE SYNONYM ord FOR oe.orders; This command is issued by the database administrator.

D. CREATE PUBLIC SYNONYM ord FOR oe.orders; This command is issued by the database administrator.

 

Answer: D

 

Question: 17

Which statement is true regarding synonyms?

 

A. Synonyms can be created for tables but not views.

B. Synonyms are used to reference only those tables that are owned by another user.

C. A public synonym and a private synonym can exist with the same name for the same table.

D. The DROP SYNONYM statement removes the synonym, and the status of the table on which the synonym has been created becomes invalid.

 

Answer: C

 

Question: 18

View the Exhibit and examine the structure of the ORD table.

 

 

 

Evaluate the following SQL statements that are executed in a user session in the specified order: CREATE SEQUENCE ord_seq;

SELECT ord_seq.nextval

FROM dual;

 

INSERT INTO ord

VALUES (ord_seq.CURRVAL, ’25-jan-2007′,101); UPDATE ord

SET ord_no= ord_seq.NEXTVAL WHERE cust_id =101;

What would be the outcome of the above statements?

 

A. All the statements would execute successfully and the ORD_NO column would contain the value 2 for the CUST_ID 101.

B. The CREATE SEQUENCE command would not execute because the minimum value and maximum value for the sequence have not been specified.

C. The CREATE SEQUENCE command would not execute because the starting value of the sequence and the increment value have not been specified.

D. All the statements would execute successfully and the ORD_NO column would have the value

20 for the CUST_ID 101 because the default CACHE value is 20.

 

Answer: A

 

Question: 19

ORD is a private synonym for the OE.ORDERS table. The user OE issues the following command:

DROP SYNONYM ord;

Which statement is true regarding the above SQL statement?

 

A. Only the synonym would be dropped.

B. The synonym would be dropped and the corresponding table would become invalid. C. The synonym would be dropped and the packages referring to the synonym would be

dropped.

D. The synonym would be dropped and any PUBLIC synonym with the same name becomes invalid.

 

Answer: A

 

Question: 20

View the Exhibit button and examine the structures of ORDERS and ORDER_ITEMS tables.

 

 

 

In the ORDERS table, ORDER_ID is the PRIMARY KEY and in the ORDER_ITEMS table, ORDER_ID and LINE_ITEM_ID form the composite primary key.

Which view can have all the DML operations performed on it?

 

A. CREATE VIEW V1

AS SELECT order_id, product_id

FROM order_items;

B. CREATE VIEW V4(or_no, or_date, cust_id)

AS SELECT order_id, order_date, customer_id

FROM orders

WHERE order_date < ’30-mar-2007′ WITH CHECK OPTION;

C. CREATE VIEW V3

AS SELECT o.order_id, o.customer_id, i.product_id

FROM orders o, order_items i

WHERE o.order_id=i.order_id; D. CREATE VIEW V2

AS SELECT order_id, line_item_id, unit_price*quantity total

FROM order_items;

 

Answer: B

 

Chapter 11: Managing Objects with Data Dictionary Views

Question: 1

Evaluate the following SELECT statement and view the Exhibit to examine its output:

 

 

 

SELECT constraint_name, constraint_type, search_condition, r_constraint_name, delete_rule, status FROM user_constraints

WHERE table_name = ORDERS

Which two statements are true about the output? (Choose two.)

 

A. In the second column, indicates a check constraint.

B. The STATUS column indicates whether the table is currently in use.

C. The R_CONSTRAINT_NAME column gives the alternative name for the constraint.

D. The column DELETE_RULE decides the state of the related rows in the child table when the corresponding row is deleted from the parent table.

 

Answer: A, D

 

Question: 2

Which statement is true regarding the SESSION_PRIVS dictionary view?

A. It contains the current object privileges available in the user session.

B. It contains the current system privileges available in the user session.

C. It contains the object privileges granted to other users by the current user session.

D. It contains the system privileges granted to other users by the current user session.

 

Answer: B

 

Question: 3

Which statements are true? (Choose all that apply.)

 

A. The data dictionary is created and maintained by the database administrator.

B. The data dictionary views can consist of joins of dictionary base tables and user-defined tables.

C. The usernames of all the users including the database administrators are stored in the data dictionary.

D. The USER_CONS_COLUMNS view should be queried to find the names of the columns to which a constraint applies.

E. Both USER_OBJECTS and CAT views provide the same information about all the objects that are owned by the user.

F. Views with the same name but different prefixes, such as DBA, ALL and USER, use the same base tables from the data dictionary

 

Answer: C, D, F

 

Question: 4

Which view would you use to display the column names and DEFAULT values for a table?

 

A. DBA_TABLES

B. DBA_COLUMNS

C. USER_COLUMNS

D. USER_TAB_COLUMNS

 

Answer: D

 

 

 

Oracle Database 10g SQL Fundamentals II

Chapter 01: Controlling User Access & Chapter 02: Managing Schema Objects

Question: 1

OE and SCOTT are the users in the database. The ORDERS table is owned by OE. Evaluate the statements issued by the DBA in the following sequence:

 

CREATE ROLE r1;

GRANT SELECT, INSERT ON oe.orders TO r1; GRANT r1 TO scott;

GRANT SELECT ON oe.orders TO scott; REVOKE SELECT ON oe.orders FROM scott;

 

What would be the outcome after executing the statements?

 

A. SCOTT would be able to query the OE.ORDERS table.

B. SCOTT would not be able to query the OE.ORDERS table.

C. The REVOKE statement would remove the SELECT privilege from SCOTT as well as from the role R1.

D. The REVOKE statement would give an error because the SELECT privilege has been granted to the role R1.

 

Answer: A

 

Question: 2

Which statement correctly grants a system privilege?

 

A. GRANT EXECUTE ON proc1

TO PUBLIC;

B. GRANT CREATE VIEW ON table1 TO

user1;

C. GRANT CREATE TABLE TO user1,user2;

D. GRANT CREATE SESSION TO ALL;

 

Answer: C

 

Question: 3

User OE, the owner of the ORDERS table, issues the following command: GRANT SELECT ,INSERT

ON orders

TO hr

WITH GRANT OPTION;

The user HR issues the following command: GRANT SELECT

ON oe.orders

TO scott;

Then, OE issues the following command: REVOKE ALL

ON orders

FROM hr;

 

Which statement is correct?

 

A. The user SCOTT loses the privilege to select rows from OE.ORDERS. B. The user SCOTT retains the privilege to select rows from OE.ORDERS.

C. The REVOKE statement generates an error because OE has to first revoke the SELECT

privilege from SCOTT.

D. The REVOKE statement generates an error because the ALL keyword cannot be used for privileges that have been granted using WITH GRANT OPTION.

 

Answer: A

 

Question: 4

SCOTT is a user in the database.

 

Evaluate the commands issued by the DBA:

 

1 – CREATE ROLE mgr;

2 – GRANT CREATE TABLE, SELECT ON oe.orders

TO mgr;

3 – GRANT mgr, create table TO SCOTT;

 

Which statement is true regarding the execution of the above commands?

 

A. Statement 1 would not execute because the WITH GRANT option is missing.

B. Statement 1 would not execute because the IDENTIFIED BY <password> clause is missing.

C. Statement 3 would not execute because role and system privileges cannot be granted together in a single GRANT statement.

D. Statement 2 would not execute because system privileges and object privileges cannot be granted together in a single GRANT command.

 

Answer: D

 

Question: 5

The user SCOTT who is the owner of ORDERS and ORDER_ITEMS tables issues the following

GRANT command: GRANT ALL

ON orders, order_items

TO PUBLIC;

What correction needs to be done to the above statement?

 

A. PUBLIC should be replaced with specific usernames.

B. ALL should be replaced with a list of specific privileges.

C. WITH GRANT OPTION should be added to the statement.

D. Separate GRANT statements are required for ORDERS and ORDER_ITEMS tables.

 

Answer: D

 

Question: 6

Which two statements are true regarding roles? (Choose two.)

 

A. A role can be granted to itself.

B. A role can be granted to PUBLIC.

C. A user can be granted only one role at any point of time.

D. The REVOKE command can be used to remove privileges but not roles from other users. E. Roles are named groups of related privileges that can be granted to users or other roles.

 

Answer: B, E

 

Question: 7

Which statement correctly differentiates a system privilege from an object privilege?

 

A. System privileges can be granted only by the DBA whereas object privileges can be granted by DBAs or the owner of the object.

B. System privileges give the rights to only create user schemas whereas object privileges give rights to manipulate objects in a schema.

C. Users require system privileges to gain access to the database whereas they require object privileges to create objects in the database.

D. A system privilege is the right to perform specific activities in a database whereas an object privilege is a right to perform activities on a specific object in the database.

 

Answer: D

 

Question: 8

View the Exhibit and examine the description of the CUSTOMERS table.

You want to add a constraint on the CUST_FIRST_NAME column of the CUSTOMERS table so that the value inserted in the column does not have numbers.

Which SQL statement would you use to accomplish the task?

 

A. ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name CHECK(REGEXP_LIKE(cust_first_name,’^A-Z’))NOVALIDATE ;

B. ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name CHECK(REGEXP_LIKE(cust_first_name,’^[0-9]’))NOVALIDATE

C. ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name

CHECK(REGEXP_LIKE(cust_first_name,'[[:alpha:]]’))NOVALIDATE ; D. ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name

CHECK(REGEXP_LIKE(cust_first_name,'[[:digit:]]’))NOVALIDATE ;

 

Answer: C

 

Question: 9

View the Exhibit and examine the structure of the EMP table which is not partitioned and not an index-organized table.

 

 

 

Evaluate the following SQL statement: ALTER TABLE emp

DROP COLUMN first_name;

Which two statements is true regarding the above command? (Choose two.)

 

A. The FIRST_NAME column would be dropped provided it does not contain any data.

B. The FIRST_NAME column would be dropped provided at least one or more columns remain in the table.

C. The FIRST_NAME column can be rolled back provided the SET UNUSED option is added to the above SQL statement.

D. The FIRST_NAME column can be dropped even if it is part of a composite PRIMARY KEY

provided the CASCADE option is used.

 

Answer: B, D

 

Question: 10

Evaluate the following SQL statement:

 

ALTER TABLE hr.emp

SET UNUSED (mgr_id);

 

Which statement is true regarding the effect of the above SQL statement?

 

A. Any synonym existing on the EMP table would have to be re-created.

B. Any constraints defined on the MGR_ID column would be removed by the above command. C. Any views created on the EMP table that include the MGR_ID column would have to be

dropped and re-created.

D. Any index created on the MGR_ID column would continue to exist until the DROP UNUSED COLUMNS command is executed.

 

Answer: B

 

Question: 11

Which statement is true regarding external tables?

 

A. The default REJECT LIMIT for external tables is UNLIMITED.

B. The data and metadata for an external table are stored outside the database.

C. ORACLE_LOADER and ORACLE_DATAPUMP have exactly the same functionality when used with an external table.

D. The CREATE TABLE AS SELECT statement can be used to unload data into regular table in the database from an external table.

 

Answer: D

 

Question: 12

View the Exhibit and examine the structure of the EMP table.

 

 

 

You executed the following command to add a primary key to the EMP table: ALTER TABLE emp

ADD CONSTRAINT emp_id_pk PRIMARY KEY (emp_id) USING INDEX emp_id_idx;

Which statement is true regarding the effect of the command?

 

A. The PRIMARY KEY is created along with a new index.

B. The PRIMARY KEY is created and it would use an existing unique index.

C. The PRIMARY KEY would be created in a disabled state because it is using an existing index.

D. The statement produces an error because the USING clause is permitted only in the CREATE TABLE command.

 

Answer: B

 

Question: 13

View the Exhibit and examine the structure of  ORD and  ORD_ITEMS tables.

 

In the ORD table, the PRIMARY KEY is ORD_NO and in the ORD_ITEMS tables the composite

PRIMARY KEY is (ORD_NO, ITEM_NO).

Which two CREATE INDEX statements are valid? (Choose two.)

 

A. CREATE INDEX ord_idx

ON ord(ord_no);

B. CREATE INDEX ord_idx

ON ord_items(ord_no); C. CREATE INDEX ord_idx

ON ord_items(item_no); D. CREATE INDEX ord_idx

ON ord,ord_items(ord_no, ord_date,qty);

 

Answer: B, C

 

Question: 14

 

Evaluate the following CREATE TABLE command: CREATE TABLE order_item

(order_id NUMBER(3), item_id NUMBER(2), qty NUMBER(4),

CONSTRAINT ord_itm_id_pk PRIMARY KEY (order_id,item_id) USING INDEX

(CREATE INDEX ord_itm_idx

ON order_item(order_id,item_id)));

Which statement is true regarding the above SQL statement?

 

A. It would execute successfully and only ORD_ITM_IDX index would be created.

B. It would give an error because the USING INDEX clause cannot be used on a composite primary key.

C. It would execute successfully and two indexes ORD_ITM_IDX and ORD_ITM_ID_PK would be created.

D. It would give an error because the USING INDEX clause is not permitted in the CREATE TABLE command.

 

Answer: A

 

Question: 15

Which mandatory clause has to be added to the following statement to successfully create an external table called EMPDET?

 

CREATE TABLE empdet

(empno CHAR(2), ename CHAR(5), deptno NUMBER(4)) ORGANIZATION EXTERNAL

(LOCATION (’emp.dat’));

 

A. TYPE

B. REJECT LIMIT

C. DEFAULT DIRECTORY

D. ACCESS PARAMETERS

 

Answer: C

 

Question: 16

Evaluate the following SQL statements that are issued in the given order:

 

CREATE TABLE emp

(emp_no NUMBER(2) CONSTRAINT emp_emp_no_pk PRIMARY KEY, ename VARCHAR2(15),

salary NUMBER(8,2),

mgr_no NUMBER(2) CONSTRAINT emp_mgr_fk REFERENCES emp); ALTER TABLE emp

DISABLE CONSTRAINT emp_emp_no_pk CASCADE; ALTER TABLE emp

ENABLE CONSTRAINT emp_emp_no_pk;

 

What would be the status of the foreign key EMP_MGR_FK?

 

A. It would be automatically enabled and deferred. B. It would be automatically enabled and immediate.

C. It would remain disabled and has to be enabled manually using the ALTER TABLE command.

 

D. It would remain disabled and can be enabled only by dropping the foreign key constraint and re-creating it.

 

Answer: C

 

Question: 17

Evaluate the following ALTER TABLE statement: ALTER TABLE orders

SET UNUSED order_date; Which statement is true?

 

A. The DESCRIBE command would still display the ORDER_DATE column.

B. ROLLBACK can be used to get back the ORDER_DATE column in the ORDERS table.

C. The ORDER_DATE column should be empty for the ALTER TABLE command to execute successfully.

D. After executing the ALTER TABLE command, you can add a new column called

ORDER_DATE to the ORDERS table.

 

Answer: D

 

Question: 18

View the Exhibit and examine the ORDERS table.

 

 

 

The ORDERS table contains data and all orders have been assigned a customer ID. Which statement would add a NOT NULL constraint to the CUSTOMER_ID column?

 

A. ALTER TABLE orders

ADD CONSTRAINT orders_cust_id_nn NOT NULL (customer_id);

B. ALTER TABLE orders

MODIFY customer_id CONSTRAINT orders_cust_id_nn NOT NULL;

C. ALTER TABLE orders

MODIFY CONSTRAINT orders_cust_id_nn NOT NULL (customer_id);

D. ALTER TABLE orders

ADD customer_id NUMBER(6)CONSTRAINT orders_cust_id_nn NOT NULL;

 

Answer: B

 

Question: 19

View the Exhibit and examine the data in EMP and DEPT tables.

 

 

In the DEPT table, DEPTNO is the PRIMARY KEY.

In the EMP table, EMPNO is the PRIMARY KEY and DEPTNO is the FOREIGN KEY referencing the DEPTNO column in the DEPT table.

What would be the outcome of the following statements executed in the given sequence? DROP TABLE emp;

FLASHBACK TABLE emp TO BEFORE DROP; INSERT INTO emp VALUES (2,COTT 10); INSERT INTO emp VALUES (3,ING 55);

 

A. Both the INSERT statements would fail because all constraints are automatically retrieved when the table is flashed back.

B. Both the INSERT statements would succeed because none of the constraints on the table are automatically retrieved when the table is flashed back.

C. Only the first INSERT statement would succeed because all the constraints except the primary key constraint are automatically retrieved after a table is flashed back.

D. Only the second INSERT statement would succeed because all the constraints except referential integrity constraints that reference other tables are retrieved automatically after the table is flashed back.

 

Answer: D

 

Question: 20

Which two statements best describe the benefits of using the WITH clause? (Choose two.)

 

A. It enables users to store the results of a query permanently.

B. It enables users to store the query block permanently in the memory and use it to create complex queries.

C. It enables users to reuse the same query block in a SELECT statement, if it occurs more than once in a complex query.

D. It can improve the performance of a large query by storing the result of a query block having the WITH clause in the user’s temporary tablespace.

 

Answer: C, D

 

Question: 21

View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS tables.

 

 

 

In the ORDERS table, ORDER_ID is the PRIMARY KEY and ORDER_DATE has the DEFAULT

value as SYSDATE.

Evaluate the following statement: UPDATE orders

SET order_date=DEFAULT

WHERE order_id IN (SELECT order_id FROM order_items

WHERE qty IS NULL);

What would be the outcome of the above statement?

 

A. The UPDATE statement would not work because the main query and the subquery use different tables.

B. The UPDATE statement would not work because the DEFAULT value can be used only in

INSERT statements.

C. The UPDATE statement would change all ORDER_DATE values to SYSDATE provided the current ORDER_DATE is NOT NULL and QTY is NULL.

D. The UPDATE statement would change all the ORDER_DATE values to SYSDATE irrespective of what the current ORDER_DATE value is for all orders where QTY is NULL.

 

Answer: D

 

Question: 22

The first DROP operation is performed on PRODUCTS table using the following command: DROP TABLE products PURGE;

Then you performed the FLASHBACK operation by using the following command: FLASHBACK TABLE products TO BEFORE DROP;

Which statement describes the outcome of the FLASHBACK command?

 

 

A. It recovers only the table structure.

B. It recovers the table structure, data, and the indexes.

C. It recovers the table structure and data but not the related indexes.

D. It is not possible to recover the table structure, data, or the related indexes.

 

Answer: D

 

Question: 23

Evaluate the following SQL statement: CREATE INDEX upper_name_idx

ON product_information(UPPER(product_name)); Which query would use the UPPER_NAME_IDX index?

 

A. SELECT UPPER(product_name) FROM product_information WHERE product_id = 2254;

B. SELECT UPPER(product_name) FROM product_information;

C. SELECT product_id

FROM product_information

WHERE UPPER(product_name) IN (‘LASERPRO’, ‘Cable’); D. SELECT product_id, UPPER(product_name)

FROM product_information

WHERE UPPER(product_name)=’LASERPRO’ OR list_price > 1000;

 

Answer: C

 

Question: 24

View the Exhibit and examine the data in the PRODUCTS table.

 

 

 

Which statement would add a column called PRICE, which cannot contain NULL?

 

A. ALTER TABLE products

ADD price NUMBER(8,2) NOT NULL; B. ALTER TABLE products

ADD price NUMBER(8,2) DEFAULT NOT NULL; C. ALTER TABLE products

ADD price NUMBER(8,2) DEFAULT 0 NOT NULL; D. ALTER TABLE products

ADD price NUMBER(8,2) DEFAULT CONSTRAINT p_nn NOT NULL;

 

Answer: C

 

Question: 25

Evaluate the following CREATE TABLE commands: CREATE TABLE orders

(ord_no NUMBER(2) CONSTRAINT ord_pk PRIMARY KEY, ord_date DATE,

cust_id NUMBER(4)); CREATE TABLE ord_items

(ord_no NUMBER(2), item_no NUMBER(3),

qty NUMBER(3) CHECK (qty BETWEEN 100 AND 200), expiry_date date CHECK (expiry_date > SYSDATE), CONSTRAINT it_pk PRIMARY KEY (ord_no,item_no),

CONSTRAINT ord_fk FOREIGN KEY(ord_no) REFERENCES orders(ord_no)); Why would the ORD_ITEMS table not get created?

 

A. SYSDATE cannot be used with the CHECK constraint.

B. The CHECK constraint cannot be used twice for the same table. C. The BETWEEN clause cannot be used for the CHECK constraint.

D. ORD_NO and ITEM_NO cannot be used as a composite primary key because ORD_NO is also the FOREIGN KEY.

 

Answer: A

 

Oracle Database 10g SQL Fundamentals I

 

Chapter 09:Using DDL Statements to Create and Manage Tables

Question: 1

Evaluate the CREATE TABLE statement: CREATE TABLE products

(product_id NUMBER(6) CONSTRAINT prod_id_pk PRIMARY KEY, product_name VARCHAR2(15));

Which statement is true regarding the PROD_ID_PK constraint?

 

A. It would be created only if a unique index is manually created first.

B. It would be created and would use an automatically created unique index.

C. It would be created and would use an automatically created no unique index.

D. It would be created and remains in a disabled state because no index is specified in the command.

 

Answer: B

 

Question: 2

Which CREATE TABLE statement is valid?

 

A. CREATE TABLE ord_details

(ord_no NUMBER(2) PRIMARY KEY, item_no NUMBER(3) PRIMARY KEY, ord_date date NOT NULL);

B. CREATE TABLE ord_details

(ord_no NUMBER(2) UNIQUE, NOT NULL, item_no NUMBER(3),

ord_date date DEFAULT SYSDATE NOT NULL); C. CREATE TABLE ord_details

(ord_no NUMBER(2) ,

item_no NUMBER(3),

ord_date date DEFAULT NOT NULL, CONSTRAINT ord_uq UNIQUE (ord_no), CONSTRAINT ord_pk PRIMARY KEY (ord_no));

D. CREATE TABLE ord_details

(ord_no NUMBER(2), item_no NUMBER(3),

ord_date date DEFAULT SYSDATE NOT NULL, CONSTRAINT ord_pk PRIMARY KEY (ord_no, item_no));

 

Answer: D

 

Question: 3

You need to create a table with the following column specifications:

 

1. Employee ID (numeric data type) for each employee

2. Employee Name, (character data type) which stores the employee name

3. Hire date, to store the date when the employee joined the organization

4. Status (character data type). It should contain the value if no data is entered.

5. Resume (character large object [CLOB] data type), which would contain the resume submitted by the employee

 

Which is the correct syntax to create this table?

 

A. CREATE TABLE EMP_1

(emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE,

e_status VARCHAR2(10) DEFAULT ‘ACTIVE’, resume CLOB(200));

B. CREATE TABLE 1_EMP

(emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE,

emp_status VARCHAR2(10) DEFAULT ‘ACTIVE’, resume CLOB);

C. CREATE TABLE 1_EMP

(emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE,

emp_status VARCHAR2(10) DEFAULT “ACTIVE”, resume CLOB);

D. CREATE TABLE EMP_1

(emp_id NUMBER, emp_name VARCHAR2(25), start_date DATE,

emp_status VARCHAR2(10) DEFAULT ‘ACTIVE’, resume CLOB);

 

Answer: D

 

Question: 4

View the Exhibit and examine the structure of the ORDERS table.

 

 

The ORDER_ID column is the PRIMARY KEY in the ORDERS table. Evaluate the following CREATE TABLE command:

CREATE TABLE new_orders(ord_id, ord_date DEFAULT SYSDATE, cust_id) AS SELECT order_id,order_date,customer_id

FROM orders;

Which statement is true regarding the above command?

 

A. The NEW_ORDERS table would not get created because the DEFAULT value cannot be specified in the column definition.

B. The NEW_ORDERS table would get created and only the NOT NULL constraint defined on the specified columns would be passed to the new table.

C. The NEW_ORDERS table would not get created because the column names in the CREATE TABLE command and the SELECT clause do not match.

D. The NEW_ORDERS table would get created and all the constraints defined on the specified columns in the ORDERS table would be passed to the new table.

 

Answer: B

 

Question: 5

Evaluate the following command: CREATE TABLE employees

(employee_id NUMBER(2) PRIMARY KEY, last_name VARCHAR2(25) NOT NULL, department_id NUMBER(2),

job_id VARCHAR2(8), salary NUMBER(10,2));

 

You issue the following command to create a view that displays the IDs and last names of the sales staff in the organization:

CREATE OR REPLACE VIEW sales_staff_vu AS SELECT employee_id, last_name,job_id

FROM employees

WHERE job_id LIKE ‘SA_%’ WITH CHECK OPTION;

Which statements are true regarding the above view? (Choose all that apply.)

 

A. It allows you to insert details of all new staff into the EMPLOYEES table.

B. It allows you to delete the details of the existing sales staff from the EMPLOYEES table. C. It allows you to update the job ids of the existing sales staff to any other job id in the

EMPLOYEES table.

D. It allows you to insert the IDs, last names and job ids of the sales staff from the view if it is used in multitable INSERT statements.

 

Answer: B, D

 

Question: 6

Evaluate the SQL statements: CREATE TABLE new_order

(orderno NUMBER(4),

booking_date TIMESTAMP WITH LOCAL TIME ZONE);

The database is located in San Francisco where the time zone is -8:00. The user is located in New York where the time zone is -5:00.

A New York user inserts the following record: INSERT INTO new_order

VALUES(1, TIMESTAMP ?007-05-10 6:00:00 -5:00?); Which statement is true?

 

A. When the New York user selects the row, booking_date is displayed as ‘007-05-10

3.00.00.000000’

B. When the New York user selects the row, booking_date is displayed as ‘2007-05-10

6.00.00.000000 -5:00’.

C. When the San Francisco user selects the row, booking_date is displayed as ‘007-05-10

3.00.00.000000’

D. When the San Francisco user selects the row, booking_date is displayed as ‘007-05-10

3.00.00.000000 -8:00’

 

Answer: C

 

Question: 7

Which two statements are true regarding constraints? (Choose two.)

 

A. A foreign key cannot contain NULL values.

B. A column with the UNIQUE constraint can contain NULL.

C. A constraint is enforced only for the INSERT operation on a table.

D. A constraint can be disabled even if the constraint column contains data.

E. All the constraints can be defined at the column level as well as the table level.

 

Answer: B, D

 

Chapter 10: Creating Other Schema Objects

Question: 1

Which two statements are true? (Choose two.)

 

A. The USER_SYNONYMS view can provide information about private synonyms.

B. The user SYSTEM owns all the base tables and user-accessible views of the data dictionary. C. All the dynamic performance views prefixed with V$ are accessible to all the database users. D. The USER_OBJECTS view can provide information about the tables and views created by the

user only.

E. DICTIONARY is a view that contains the names of all the data dictionary views that the user can access.

 

Answer: A, E

 

Question: 2

Evaluate the following CREATE SEQUENCE statement: CREATE SEQUENCE seq1

START WITH 100

INCREMENT BY 10

MAXVALUE 200

CYCLE NOCACHE;

The sequence SEQ1 has generated numbers up to the maximum limit of 200. You issue the following SQL statement:

SELECT seq1.nextval FROM dual;

What is displayed by the SELECT statement?

 

A. 1

B. 10

C. 100

D. an error

Answer: A

 

Question: 3

EMPDET is an external table containing the columns EMPNO and ENAME. Which command would work in relation to the EMPDET table?

 

A. UPDATE empdet

SET ename = ‘Amit’ WHERE empno = 1234;

B. DELETE FROM empdet

WHERE ename LIKE ‘J%’;

C. CREATE VIEW empvu

AS

SELECT * FROM empdept;

D. CREATE INDEX empdet_idx

ON empdet(empno);

 

Answer: C

 

Question: 4

View the Exhibit and examine the data in ORDERS and ORDER_ITEMS tables.

 

 

You need to create a view that displays the ORDER ID, ORDER_DATE, and the total number of items in each order.

Which CREATE VIEW statement would create the view successfully?

 

A. CREATE OR REPLACE VIEW ord_vu (order_id,order_date) AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)

“NO OF ITEMS”

FROM orders o JOIN order_items i

ON (o.order_id = i.order_id)

GROUP BY o.order_id,o.order_date; B. CREATE OR REPLACE VIEW ord_vu

AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)

“NO OF ITEMS”

FROM orders o JOIN order_items i

ON (o.order_id = i.order_id)

GROUP BY o.order_id,o.order_date; C. CREATE OR REPLACE VIEW ord_vu

AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id) FROM orders o JOIN order_items i

ON (o.order_id = i.order_id)

GROUP BY o.order_id,o.order_date; D. CREATE OR REPLACE VIEW ord_vu

AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)||’ NO OF ITEMS’ FROM orders o JOIN order_items i

ON (o.order_id = i.order_id)

GROUP BY o.order_id,o.order_date

WITH CHECK OPTION;

 

Answer: B

 

Question: 5

You need to create a table for a banking application with the following considerations:

 

1) You want a column in the table to store the duration of the credit period.

2) The data in the column should be stored in a format such that it can be easily added and subtracted with

3) date type data without using the conversion functions.

4) The maximum period of the credit provision in the application is 30 days.

5) The interest has to be calculated for the number of days an individual has taken a credit for.

 

Which data type would you use for such a column in the table?

 

A. INTERVAL YEAR TO MONTH

B. INTERVAL DAY TO SECOND

C. TIMESTAMP WITH TIME ZONE

D. TIMESTAMP WITH LOCAL TIME ZONE

 

Answer: B

 

Question: 6

Which two statements are true regarding views? (Choose two.)

 

A. A simple view in which column aliases have been used cannot be updated.

B. A subquery used in a complex view definition cannot contain group functions or joins.

C. Rows cannot be deleted through a view if the view definition contains the DISTINCT keyword. D. Rows added through a view are deleted from the table automatically when the view is

dropped.

E. The OR REPLACE option is used to change the definition of an existing view without dropping and re-creating it.

F. The WITH CHECK OPTION constraint can be used in a view definition to restrict the columns displayed through the view.

 

Answer: C, E

 

Question: 7

Which two statements are true about sequences created in a single instance database? (Choose two.)

 

A. The numbers generated by a sequence can be used only for one table.

B. DELETE <sequencename> would remove a sequence from the database.

C. CURRVAL is used to refer to the last sequence number that has been generated.

D. When the MAXVALUE limit for a sequence is reached, you can increase the MAXVALUE limit by using the ALTER SEQUENCE statement.

E. When a database instance shuts down abnormally, the sequence numbers that have been cached but not used would be available once again when the database instance is restarted.

 

Answer: C, D

 

Question: 8

Which statements are correct regarding indexes? (Choose all that apply.)

 

A. When a table is dropped, the corresponding indexes are automatically dropped.

B. For each DML operation performed, the corresponding indexes are automatically updated.

C. Indexes should be created on columns that are frequently referenced as part of an expression.

D. A non-deferrable PRIMARY KEY or UNIQUE KEY constraint in a table automatically creates a

unique index.

 

Answer: A, B, D

 

Question: 9

The ORDERS table belongs to the user OE. OE has granted the SELECT privilege on the

ORDERS table to the user HR.

Which statement would create a synonym ORD so that HR can execute the following query successfully?

SELECT * FROM ord;

 

A. CREATE SYNONYM ord FOR orders; This command is issued by OE.

B. CREATE PUBLIC SYNONYM ord FOR orders; This command is issued by OE.

C. CREATE SYNONYM ord FOR oe.orders; This command is issued by the database administrator.

D. CREATE PUBLIC SYNONYM ord FOR oe.orders; This command is issued by the database administrator.

 

Answer: D

 

Question: 10

Which statement is true regarding synonyms?

 

A. Synonyms can be created for tables but not views.

B. Synonyms are used to reference only those tables that are owned by another user.

C. A public synonym and a private synonym can exist with the same name for the same table.

D. The DROP SYNONYM statement removes the synonym, and the status of the table on which the synonym has been created becomes invalid.

 

Answer: C

 

Question: 11

View the Exhibit and examine the structure of the ORD table.

 

 

 

Evaluate the following SQL statements that are executed in a user session in the specified order: CREATE SEQUENCE ord_seq;

SELECT ord_seq.nextval

FROM dual;

 

INSERT INTO ord

VALUES (ord_seq.CURRVAL, ’25-jan-2007′,101); UPDATE ord

SET ord_no= ord_seq.NEXTVAL WHERE cust_id =101;

What would be the outcome of the above statements?

 

A. All the statements would execute successfully and the ORD_NO column would contain the value 2 for the CUST_ID 101.

B. The CREATE SEQUENCE command would not execute because the minimum value and maximum value for the sequence have not been specified.

C. The CREATE SEQUENCE command would not execute because the starting value of the sequence and the increment value have not been specified.

D. All the statements would execute successfully and the ORD_NO column would have the value

20 for the CUST_ID 101 because the default CACHE value is 20.

 

Answer: A

 

Question: 12

ORD is a private synonym for the OE.ORDERS table. The user OE issues the following command:

DROP SYNONYM ord;

Which statement is true regarding the above SQL statement?

 

A. Only the synonym would be dropped.

B. The synonym would be dropped and the corresponding table would become invalid. C. The synonym would be dropped and the packages referring to the synonym would be

dropped.

D. The synonym would be dropped and any PUBLIC synonym with the same name becomes invalid.

 

Answer: A

 

Question: 13

View the Exhibit button and examine the structures of ORDERS and ORDER_ITEMS tables.

 

 

 

In the ORDERS table, ORDER_ID is the PRIMARY KEY and in the ORDER_ITEMS table, ORDER_ID and LINE_ITEM_ID form the composite primary key.

Which view can have all the DML operations performed on it?

 

A. CREATE VIEW V1

AS SELECT order_id, product_id

FROM order_items;

B. CREATE VIEW V4(or_no, or_date, cust_id)

AS SELECT order_id, order_date, customer_id

FROM orders

WHERE order_date < ’30-mar-2007′ WITH CHECK OPTION;

C. CREATE VIEW V3

AS SELECT o.order_id, o.customer_id, i.product_id

FROM orders o, order_items i

WHERE o.order_id=i.order_id; D. CREATE VIEW V2

AS SELECT order_id, line_item_id, unit_price*quantity total

FROM order_items;

 

Answer: B

 

Chapter 11: Managing Objects with Data Dictionary Views

Question: 1

Evaluate the following SELECT statement and view the Exhibit to examine its output:

 

 

 

SELECT constraint_name, constraint_type, search_condition, r_constraint_name, delete_rule, status FROM user_constraints

WHERE table_name = ORDERS

Which two statements are true about the output? (Choose two.)

 

A. In the second column, indicates a check constraint.

B. The STATUS column indicates whether the table is currently in use.

C. The R_CONSTRAINT_NAME column gives the alternative name for the constraint.

D. The column DELETE_RULE decides the state of the related rows in the child table when the corresponding row is deleted from the parent table.

 

Answer: A, D

 

Question: 2

Which statement is true regarding the SESSION_PRIVS dictionary view?

A. It contains the current object privileges available in the user session.

B. It contains the current system privileges available in the user session.

C. It contains the object privileges granted to other users by the current user session.

D. It contains the system privileges granted to other users by the current user session.

 

Answer: B

 

Question: 3

Which statements are true? (Choose all that apply.)

 

A. The data dictionary is created and maintained by the database administrator.

B. The data dictionary views can consist of joins of dictionary base tables and user-defined tables.

C. The usernames of all the users including the database administrators are stored in the data dictionary.

D. The USER_CONS_COLUMNS view should be queried to find the names of the columns to which a constraint applies.

E. Both USER_OBJECTS and CAT views provide the same information about all the objects that are owned by the user.

F. Views with the same name but different prefixes, such as DBA, ALL and USER, use the same base tables from the data dictionary

 

Answer: C, D, F

 

Question: 4

Which view would you use to display the column names and DEFAULT values for a table?

 

A. DBA_TABLES

B. DBA_COLUMNS

C. USER_COLUMNS

D. USER_TAB_COLUMNS

 

Answer: D

 

 

 

1991 D0 1 T0