Docsity

Oracle Database SQL Certified Associate Practice Test Exam, Exams of Database Programming

Toggle sidebar
bg1
Oracle Database SQL Certified Associate
Practice Test Exam
1. Which query correctly displays the last name and department
name for all employees, including those without a department?
A) SELECT e.last_name, d.department_name FROM employees
e INNER JOIN departments d ON e.department_id =
d.department_id
B) SELECT e.last_name, d.department_name FROM employees
e LEFT OUTER JOIN departments d ON e.department_id =
d.department_id
C) SELECT e.last_name, d.department_name FROM employees
e RIGHT OUTER JOIN departments d ON e.department_id =
d.department_id
D) SELECT e.last_name, d.department_name FROM employees
e FULL OUTER JOIN departments d ON e.department_id =
d.department_id
Correct Answer: B
Rationale: A LEFT OUTER JOIN preserves all rows from the left
table (employees), even when no matching department exists.
INNER JOIN would exclude employees without departments,
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b

Partial preview of the text

Download Oracle Database SQL Certified Associate Practice Test Exam and more Exams Database Programming in PDF only on Docsity!

Oracle Database SQL Certified Associate

Practice Test Exam

  1. Which query correctly displays the last name and department name for all employees, including those without a department? A) SELECT e.last_name, d.department_name FROM employees e INNER JOIN departments d ON e.department_id = d.department_id B) SELECT e.last_name, d.department_name FROM employees e LEFT OUTER JOIN departments d ON e.department_id = d.department_id C) SELECT e.last_name, d.department_name FROM employees e RIGHT OUTER JOIN departments d ON e.department_id = d.department_id D) SELECT e.last_name, d.department_name FROM employees e FULL OUTER JOIN departments d ON e.department_id = d.department_id Correct Answer: B Rationale: A LEFT OUTER JOIN preserves all rows from the left table (employees), even when no matching department exists. INNER JOIN would exclude employees without departments,

RIGHT OUTER JOIN would preserve departments, and FULL OUTER JOIN would include unmatched rows from both sides.

  1. What is the result of the following query: SELECT NVL(NULL, 'A') FROM DUAL? A) NULL B) 'A' C) 0 D) Error Correct Answer: B Rationale: NVL returns the second argument when the first argument is NULL. NVL(NULL, 'A') evaluates to 'A' because the first expression is NULL.
  2. Which statement about the WHERE clause is true? A) It can only filter rows after grouping has occurred B) It filters rows before any grouping or aggregation takes place C) It can use group functions to filter results D) It must always reference a column alias

B) Eliminates duplicate rows from the result set C) Restricts the number of rows returned D) Groups rows by a specified column Correct Answer: B Rationale: DISTINCT eliminates duplicate rows from the output. It applies to all columns in the SELECT list, not just the first column.

  1. Which function returns the current date and time from the database server? A) TODAY() B) SYSDATE C) NOW() D) GETDATE() Correct Answer: B Rationale: SYSDATE returns the current date and time from the database server. CURRENT_DATE returns the date in the session time zone.
  1. What is the correct syntax to concatenate two columns in Oracle SQL? A) SELECT first_name + last_name FROM employees B) SELECT first_name || last_name FROM employees C) SELECT CONCAT(first_name, last_name) FROM employees D) Both B and C Correct Answer: D Rationale: Both the || operator and the CONCAT function can concatenate strings in Oracle SQL. The + operator is for arithmetic, not string concatenation.
  2. Which clause is used to filter groups of rows after aggregation? A) WHERE B) HAVING C) GROUP BY D) ORDER BY

D) MINUS

Correct Answer: B Rationale: UNION ALL combines result sets and retains all duplicate rows. UNION removes duplicates, INTERSECT returns common rows, and MINUS returns rows from the first query not in the second.

  1. What happens when you compare a NULL value using the equality operator (=)? A) It returns TRUE if both values are NULL B) It returns FALSE if both values are NULL C) It returns UNKNOWN, and the row is not included in the result D) It raises an error Correct Answer: C Rationale: NULL represents an unknown value. Any comparison with NULL using =, <>, <, or > returns UNKNOWN, and rows with UNKNOWN conditions are excluded from results. Use IS NULL or IS NOT NULL instead.
  1. Which function converts a character string to a date? A) TO_CHAR B) TO_DATE C) TO_NUMBER D) CONVERT Correct Answer: B Rationale: TO_DATE converts a character string to a DATE value using a specified format model. TO_CHAR converts dates or numbers to strings.
  2. What is the result of TRUNC(45.678, 1)? A) 45 B) 45. C) 45. D) 46 Correct Answer: B

C) INNER JOIN

D) FULL OUTER JOIN

Correct Answer: C Rationale: INNER JOIN returns only rows where the join condition is satisfied in both tables. Outer joins include unmatched rows from one or both tables.

  1. What is the correct syntax to add a new column to an existing table? A) INSERT INTO table_name ADD column_name datatype B) ALTER TABLE table_name ADD column_name datatype C) MODIFY TABLE table_name ADD column_name datatype D) UPDATE TABLE table_name ADD column_name datatype Correct Answer: B Rationale: ALTER TABLE ... ADD is the DDL statement for adding columns to an existing table. INSERT adds rows, not columns.
  1. Which command permanently removes a table and its structure from the database? A) DELETE FROM table_name B) TRUNCATE TABLE table_name C) DROP TABLE table_name D) REMOVE TABLE table_name Correct Answer: C Rationale: DROP TABLE removes both the data and the table structure. DELETE removes rows but keeps the table. TRUNCATE removes all rows but keeps the structure.
  2. What does the COMMIT statement do? A) Rolls back the current transaction B) Makes all changes in the current transaction permanent C) Deletes all rows in a table D) Creates a savepoint Correct Answer: B

D) To create a view Correct Answer: B Rationale: A sequence generates sequential numeric values, commonly used for primary key generation. It is independent of any table.

  1. Which function returns the number of rows in a table, including rows with NULL values? A) COUNT(column_name) B) COUNT() C) SUM() D) TOTAL() Correct Answer: B Rationale: COUNT() counts all rows regardless of NULL values. COUNT(column_name) counts only rows where the specified column is not NULL.
  2. What is the result of ROUND(15.193, 1)?

A) 15.

B) 15.

C) 15.

D) 16

Correct Answer: B Rationale: ROUND rounds a number to the specified number of decimal places. ROUND(15.193, 1) rounds to one decimal place, giving 15.2.

  1. Which clause is used to sort the result set in descending order? A) ORDER BY column_name ASC B) ORDER BY column_name DESC C) SORT BY column_name DESC D) GROUP BY column_name DESC Correct Answer: B Rationale: ORDER BY with the DESC keyword sorts results in descending order. ASC is the default for ascending order.

Rationale: A view is a virtual table defined by a query. It does not store data physically (unless materialized) and can be queried like a regular table.

  1. What does the COALESCE function do? A) Returns the first non-NULL expression from its argument list B) Returns the last non-NULL expression C) Converts NULL to zero D) Raises an error when NULL is encountered Correct Answer: A Rationale: COALESCE returns the first non-NULL value in its argument list. It is more flexible than NVL because it can take multiple arguments.
  2. Which statement about the MERGE statement is true? A) It can only insert new rows B) It can conditionally insert, update, or delete rows in a target table based on a source table C) It is a DDL statement

D) It cannot use subqueries Correct Answer: B Rationale: MERGE performs conditional inserts, updates, and deletes in a single statement by comparing a source and target table.

  1. What is the purpose of the WITH CHECK OPTION clause in a view? A) To encrypt the view definition B) To prevent changes that would make rows invisible through the view C) To check for NULL values D) To validate data types Correct Answer: B Rationale: WITH CHECK OPTION ensures that any INSERT or UPDATE through the view satisfies the view's WHERE clause, preventing rows from disappearing from the view after modification.
  1. Which statement about primary keys is true? A) A table can have multiple primary keys B) Primary key columns can contain NULL values C) A primary key uniquely identifies each row and cannot contain NULL values D) Primary keys are optional for every table Correct Answer: C Rationale: A primary key enforces entity integrity by ensuring each row is uniquely identifiable. It cannot contain NULL values and only one primary key is allowed per table.
  2. What is the purpose of a foreign key? A) To uniquely identify rows in a table B) To enforce a relationship between two tables C) To sort data automatically D) To encrypt sensitive data Correct Answer: B

Rationale: A foreign key references a primary or unique key in another table, enforcing referential integrity between the two tables.

  1. Which command removes all rows from a table without logging individual row deletions and cannot be rolled back? A) DELETE FROM table_name B) TRUNCATE TABLE table_name C) DROP TABLE table_name D) REMOVE FROM table_name Correct Answer: B Rationale: TRUNCATE removes all rows quickly without generating undo for individual rows. It is a DDL operation and cannot be rolled back.
  2. What is the correct syntax to create a synonym for a table? A) CREATE SYNONYM synonym_name FOR table_name B) MAKE SYNONYM synonym_name FOR table_name C) ADD SYNONYM synonym_name TO table_name