1Z0-051 Premium Bundle

1Z0-051 Premium Bundle

Oracle Database: SQL Fundamentals I Certification Exam

4.5 
(26970 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
May 20, 2024Last update

Oracle 1Z0-051 Free Practice Questions

Q1. - (Topic 2) 

Examine the data in the ORD_ITEMS table: 

ORD_NO ITEM_NO QTY 

1 111 10 

1 222 20 

1 333 30 

2 333 30 

2 444 40 

3 111 40 

Evaluate the following query: 

SQL>SELECT item_no, AVG(qty) 

FROM ord_items 

HAVING AVG(qty) > MIN(qty) * 2 

GROUP BY item_no; 

Which statement is true regarding the outcome of the above query? 

A. It gives an error because the HAVING clause should be specified after the GROUP BY clause. 

B. It gives an error because all the aggregate functions used in the HAVING clause must be specified in the SELECT list. 

C. It displays the item nos with their average quantity where the average quantity is more than double the minimum quantity of that item in the table. 

D. It displays the item nos with their average quantity where the average quantity is more than double the overall minimum quantity of all the items in the table. 

Answer:

Q2. - (Topic 2) 

The DBA issues this SQL command: 

CREATE USER Scott 

IDENTIFIED by tiger; 

What privileges does the user Scott have at this point? 

A. No privileges. 

B. Only the SELECT privilege. 

C. Only the CONNECT privilege. 

D. All the privileges of a default user. 

Answer:

Explanation: 

There are no privileges for the user Scott at this point. They are not added themselves to 

the user immediately after creation. The DBA needs to grant all privileges explicitly. 

Incorrect Answers 

B:There are no privileges for the user Scott at this point. SELECT privilege needs to be 

added to the user Scott. 

C:There are no privileges for the user Scott at this point. CONNECT privilege needs to be 

added to the user Scott. 

D:There is no default user in Oracle. 

OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 348-351 

Chapter 8: User Access in Oracle 

Q3. - (Topic 1) 

You issue the following command to drop the PRODUCTS table: 

SQL>DROP TABLE products; 

What is the implication of this command? (Choose all that apply.) 

A. All data in the table are deleted but the table structure will remain 

B. All data along with the table structure is deleted 

C. All views and synonyms will remain but they are invalidated 

D. The pending transaction in the session is committed 

E. All indexes on the table will remain but they are invalidated 

Answer: B,C,D 

Q4. - (Topic 1) 

View the Exhibit and examine the structure of the PRODUCTS table. You need to generate a report in the following format: CATEGORIES 5MP Digital Photo Camera's category is Photo Y Box's category is Electronics Envoy Ambassador's category is Hardware Which two queries would give the required output? (Choose two.) 

A. SELECT prod_name || q'''s category is ' || prod_category CATEGORIES FROM products; 

B. SELECT prod_name || q'['s ]'category is ' || prod_category CATEGORIES FROM products; 

C. SELECT prod_name || q'\'s\' || ' category is ' || prod_category CATEGORIES FROM products; 

D. SELECT prod_name || q'<'s >' || 'category is ' || prod_category CATEGORIES FROM products; 

Answer: C,D 

Explanation: 

So, how are words that contain single quotation marks dealt with? There are essentially two mechanisms available. The most popular of these is to add an additional single quotation mark next to each naturally occurring single quotation mark in the character string Oracle offers a neat way to deal with this type of character literal in the form of the alternative quote (q) operator. Notice that the problem is that Oracle chose the single quote characters as the special pair of symbols that enclose or wrap any other character literal. These character-enclosing symbols could have been anything other than single quotation marks. Bearing this in mind, consider the alternative quote (q) operator. The q operator enables you to choose from a set of possible pairs of wrapping symbols for character literals as alternatives to the single quote symbols. The options are any single-byte or multibyte character or the four brackets: (round brackets), {curly braces}, [squarebrackets], or <angle brackets>. Using the q operator, the character delimiter can effectively be changed from a single quotation mark to any other character The syntax of the alternative quote operator is as follows: q'delimiter'character literal which may include the single quotes delimiter' where delimiter can be any character or bracket. 

Alternative Quote (q) Operator 

Specify your own quotation mark delimiter. 

Select any delimiter. 

Increase readability and usability. 

SELECT department_name || q'[ Department's Manager Id: ]' 

|| manager_id 

AS "Department and Manager" 

FROM departments; 

Alternative Quote (q) Operator 

Many SQL statements use character literals in expressions or conditions. If the literal itself 

contains a single quotation mark, you can use the quote (q) operator and select your own 

quotation mark delimiter. 

You can choose any convenient delimiter, single-byte or multibyte, or any of the following 

character pairs: [ ], { }, ( ), or < >. In the example shown, the string contains a single quotation mark, which is normally interpreted as a delimiter of a character string. By using the q operator, however, brackets [] are used as the quotation mark delimiters. The string between the brackets delimiters is interpreted as a literal character string. 

Q5. - (Topic 2) 

Which four are valid Oracle constraint types? (Choose four.) 

A. CASCADE 

B. UNIQUE 

C. NONUNIQUE 

D. CHECK 

E. PRIMARY KEY 

F. CONSTANT 

G. NOT NULL 

Answer: B,D,E,G 

Explanation: 

Oracle constraint type is Not Null, Check, Primary Key, Foreign Key and Unique Incorrect Answer: AIs not Oracle constraint CIs not Oracle constraint FIs not Oracle constraint Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 10-3 

Q6. - (Topic 2) 

Examine the structure of the CUSTOMERS table: 

CUSTNO is the PRIMARY KEY in the table. You want to find out if any customers' details have been entered more than once using different CUSTNO, by listing all the duplicate names. 

Which two methods can you use to get the required result? (Choose two.) 

A. self-join 

B. subquery 

C. full outer-join with self-join 

D. left outer-join with self-join 

E. right outer-join with self-join 

Answer: A,B 

Q7. - (Topic 2) 

Examine the statement: 

GRANT select, insert, update 

ON student_grades 

TO manager 

WITH GRANT OPTION; 

Which two are true? (Choose two.) 

A. MANAGER must be a role. 

B. It allows the MANAGER to pass the specified privileges on to other users. 

C. It allows the MANAGER to create tables that refer to the STUDENT_GRADES table. 

D. It allows the MANAGER to apply all DML statements on the STUDENT_GRADES table. 

E. It allows the MANAGER the ability to select from, insert into, and update the STUDENT_GRADES table. 

F. It allows the MANAGER the ability to select from, delete from, and update the STUDENT_GRADES table. 

Answer: B,E 

Explanation: 

GRANT ROLE to ROLE/USER 

Incorrect Answer: ARole can be grant to user CCreate table privilege is not granted DExecute privilege is not granted FDelete privilege is not granted 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 13-15 

Q8. - (Topic 2) 

Which object privileges can be granted on a view? 

A. none 

B. DELETE, INSERT,SELECT 

C. ALTER, DELETE, INSERT, SELECT 

D. DELETE, INSERT, SELECT, UPDATE 

Answer:

Explanation: Object privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE. 

Incorrect Answer: AObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE BObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE CObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 13-12 

Q9. - (Topic 1) 

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

All products have a list price. 

You issue the following command to display the total price of each product after a discount of 25% and a tax of 15% are applied on it. Freight charges of S100 have to be applied to all the products. 

What would be the outcome if all the parentheses are removed from the above statement? 

A. It produces a syntax error. 

B. The result remains unchanged. 

C. The total price value would be lower than the correct value. 

D. The total price value would be higher than the correct value. 

Answer:

Q10. - (Topic 2) 

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

You want to display the category with the maximum number of items. You issue the following query: 

SQL>SELECT COUNT(*),prod_category_id FROM products GROUP BY prod_category_id HAVING COUNT(*) = (SELECT MAX(COUNT(*)) FROM products); 

What is the outcome? 

A. It executes successfully and gives the correct output. 

B. It executes successfully but does not give the correct output. 

C. It generates an error because the subquery does not have a GROUP BY clause. 

D. It generates an error because = is not valid and should be replaced by the IN operator. 

Answer:

Q11. - (Topic 2) 

Which statements are true regarding the FOR UPDATE clause in a SELECT statement? (Choose all that apply.) 

A. It locks only the columns specified in the SELECT list. 

B. It locks the rows that satisfy the condition in the SELECT statement. 

C. It can be used only in SELECT statements that are based on a single table. 

D. It can be used in SELECT statements that are based on a single or multiple tables. 

E. After it is enforced by a SELECT statement, no other query can access the same rows until a COMMIT or ROLLBACK is issued. 

Answer: B,D 

Explanation: 

FOR UPDATE Clause in a SELECT Statement Locks the rows in the EMPLOYEES table where job_id is SA_REP. Lock is released only when you issue a ROLLBACK or a COMMIT. If the SELECT statement attempts to lock a row that is locked by another user, the database waits until the row is available, and then returns the results of the SELECT statement. FOR UPDATE Clause in a SELECT Statement When you issue a SELECT statement against the database to query some records, no locks are placed on the selected rows. In general, this is required because the number of records locked at any given time is (by default) kept to the absolute minimum: only those records that have been changed but not yet committed are locked. Even then, others will be able to read those records as they appeared before the change (the “before image” of the data). There are times, however, when you may want to lock a set of records even before you change them in your program. Oracle offers the FOR UPDATE clause of the SELECT statement to perform this locking. When you issue a SELECT...FOR UPDATE statement, the relational database management system (RDBMS) automatically obtains exclusive row-level locks on all the rows identified by the SELECT statement, thereby holding the records “for your changes only.” No one else will be able to change any of these records until you perform a ROLLBACK or a COMMIT. You can append the optional keyword NOWAIT to the FOR UPDATE clause to tell the Oracle server not to wait if the table has been locked by another user. In this case, control will be returned immediately to your program or to your SQL Developer environment so that you can perform other work, or simply wait for a period of time before trying again. Without the NOWAIT clause, your process will block until the table is available, when the locks are released by the other user through the issue of a COMMIT or a ROLLBACK command. 

Q12. - (Topic 1) 

You need to design a student registration database that contains several tables storing academic information. 

The STUDENTS table stores information about a student. The STUDENT_GRADES table stores information about the student's grades. Both of the tables have a column named STUDENT_ID. The STUDENT_ID column in the STUDENTS table is a primary key. 

You need to create a foreign key on the STUDENT_ID column of the STUDENT_GRADES table that points to the STUDENT_ID column of the STUDENTS table. Which statement creates the foreign key? 

A. CREATE TABLE student_grades (student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT student_id_fk REFERENCES (student_id) FOREIGN KEY students(student_id)); 

B. CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id)); 

C. CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT FOREIGN KEY (student_id) REFERENCES students(student_id)); 

D. CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id)); 

Answer:

Explanation: CONSTRAINT name FOREIGN KEY (column_name) REFERENCES table_name (column_name); 

Incorrect Answer: Ainvalid syntax Binvalid syntax Cinvalid syntax 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 10-14 

Q13. - (Topic 2) 

The DBA issues this SQL command: 

CREATE USER scott IDENTIFIED by tiger; 

What privileges does the user Scott have at this point? 

A. no privileges 

B. only the SELECT privilege 

C. only the CONNECT privilege 

D. all the privileges of a default user 

Answer:

Explanation: 

when a user is created, by default no privilege is granted 

Incorrect Answer: 

BSELECT is not grant 

CCONNECT is not grant 

Ddefault profile is grant by default not privilege. 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 13-6 

Q14. - (Topic 2) 

What is true about sequences? 

A. Once created, a sequence belongs to a specific schema. 

B. Once created, a sequence is linked to a specific table. 

C. Once created, a sequence is automatically available to all users. 

D. Only the DBA can control which sequence is used by a certain table. 

E. Once created, a sequence is automatically used in all INSERT and UPDATE statements. 

Answer:

Q15. - (Topic 1) 

Examine the structure and data of the CUSTJTRANS table: 

CUSTJRANS 

Name Null? Type 

CUSTNO NOT NULL CHAR(2) TRANSDATE DATE TRANSAMT NUMBER(6.2) CUSTNO TRANSDATE TRANSAMT 

11 01-JAN-07 1000 

22 01-FEB-07 2000 

33 01-MAR-07 3000 

Dates are stored in the default date format dd-mon-rr in the CUSTJTRANS table. Which three SQL statements would execute successfully? (Choose three.) 

A. SELECT transdate + '10' FROM custjrans; 

B. SELECT * FROM custjrans WHERE transdate = '01-01-07': 

C. SELECT transamt FROM custjrans WHERE custno > '11': 

D. SELECT * FROM custjrans WHERE transdate='01-JANUARY-07': 

E. SELECT custno - 'A' FROM custjrans WHERE transamt > 2000: 

Answer: A,C,D 

START 1Z0-051 EXAM