




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which Oracle data type is best suited for storing a monetary amount with two decimal places? A) VARCHAR B) NUMBER(10,2) C) DATE D) CLOB Answer: B Explanation: NUMBER(10,2) stores up to 10 digits with 2 after the decimal, ideal for monetary values. Question 2. In an Entity-Relationship Diagram, which symbol represents a weak entity? A) Double rectangle B) Single rectangle C) Diamond D) Ellipse Answer: A Explanation: A double rectangle denotes a weak entity that depends on another entity for its primary key. Question 3. Which SQL clause is used to eliminate duplicate rows from a result set? A) UNIQUE B) DISTINCT C) GROUP BY D) HAVING Answer: B
Explanation: DISTINCT removes duplicate rows, returning only unique combinations of selected columns. Question 4. What does the SQLPlus command DESCRIBE EMP show?* A) The data in the EMP table B) The DDL of EMP C) Column names, data types, and nullability of EMP D) The number of rows in EMP Answer: C Explanation: DESCRIBE lists column metadata such as name, datatype, and whether nulls are allowed. Question 5. Which operator concatenates two character strings in Oracle SQL? A) + B) && C) || D) CONCAT() Answer: C Explanation: The double-pipe (||) operator joins two strings together. Question 6. How would you display the literal text “O'Reilly” in a SELECT statement without causing a syntax error? A) SELECT 'O'Reilly' FROM dual; B) SELECT q'[O'Reilly]' FROM dual; C) SELECT "O'Reilly" FROM dual; D) SELECT 'O''Reilly' FROM dual;
Answer: C Explanation: ROUND without a second argument rounds to the nearest whole number. Question 10. What is the result of SELECT MOD(27,5) FROM dual? A) 2 B) 5 C) 27 D) 0 Answer: A Explanation: MOD returns the remainder of 27 divided by 5, which is 2. Question 11. Which date function returns the current system date and time, including fractional seconds? A) SYSDATE B) CURRENT_DATE C) SYSTIMESTAMP D) LOCALTIMESTAMP Answer: C Explanation: SYSTIMESTAMP provides date, time, and fractional seconds with time-zone information. Question 12. How would you add 45 days to the current date in a query? A) SELECT SYSDATE + 45 FROM dual; B) SELECT ADD_DAYS(SYSDATE,45) FROM dual; C) SELECT DATEADD(SYSDATE,45) FROM dual; D) SELECT SYSDATE + INTERVAL '45' DAY FROM dual;
Answer: A Explanation: Adding a number to a DATE adds that many days. Question 13. Which function returns the number of months between two dates? A) MONTHS_BETWEEN B) ADD_MONTHS C) LAST_DAY D) NEXT_DAY Answer: A Explanation: MONTHS_BETWEEN calculates the fractional number of months between two dates. Question 14. What is the difference between SYSDATE and CURRENT_DATE? A) SYSDATE returns UTC, CURRENT_DATE returns session time zone. B) SYSDATE includes time, CURRENT_DATE returns only the date. C) SYSDATE is based on the database server, CURRENT_DATE is based on the session time zone. D) No difference; they are synonyms. Answer: C Explanation: SYSDATE uses the database server’s clock, while CURRENT_DATE respects the session’s time zone. Question 15. Which clause filters rows before grouping occurs? A) WHERE B) HAVING C) ORDER BY
Question 18. Which substitution variable syntax prompts the user only once and reuses the value? A) &deptno B) &&deptno C) &&&deptno D) :deptno Answer: B Explanation: && defines a variable that is retained for the session after the first prompt. Question 19. What does the SQLPlus command DEFINE do?* A) Executes a PL/SQL block. B) Shows the value of a substitution variable. C) Sets a variable’s value without prompting. D) Turns on command verification. Answer: C Explanation: DEFINE assigns a value to a substitution variable. Question 20. Which character function returns the position of a substring within a string? A) SUBSTR B) INSTR C) POSITION D) LOCATE Answer: B Explanation: INSTR returns the starting index of the searched substring.
Question 21. What will the expression SUBSTR('Oracle',2,3) return? A) Orc B) rac C) Rac D) ace Answer: B Explanation: Starting at position 2, three characters are “rac”. Question 22. Which function can be used to pad a string on the left with a specific character? A) RPAD B) LPAD C) TRIM D) SUBSTR Answer: B Explanation: LPAD adds characters to the left side of a string to reach a specified length. Question 23. How does the NVL function behave? A) Returns the second argument if the first is NOT NULL. B) Returns the first argument if it is NOT NULL; otherwise the second. C) Returns NULL if both arguments are NULL. D) Replaces NULL with a zero. Answer: B Explanation: NVL(expr1,expr2) returns expr1 when it is not null; otherwise expr2.
Explanation: The format model inserts a comma as a thousands separator. Question 27. Which function returns the first non-NULL expression from a list? A) NVL B) COALESCE C) NULLIF D) DECODE Answer: B Explanation: COALESCE evaluates arguments left-to-right and returns the first that is not NULL. Question 28. How does the NULLIF function work? A) Returns NULL if the two arguments are equal; otherwise returns the first argument. B) Returns the first argument if it is NULL. C) Returns the second argument when the first is NULL. D) Replaces NULL with a default value. Answer: A Explanation: NULLIF(expr1,expr2) yields NULL when expr1 = expr2; otherwise expr1. Question 29. Which of the following is a correct use of the DECODE function? A) DECODE(status,'A','Active','I','Inactive','Unknown') B) DECODE(status = 'A','Active','I','Inactive','Unknown') C) DECODE(status,'A','Active') WHEN status='I' THEN 'Inactive' END D) DECODE(status) WHEN 'A' THEN 'Active' END
Answer: A Explanation: DECODE compares the first argument to each subsequent value and returns the matching result. Question 30. Which aggregate function counts all rows, including those with NULL values in the column? A) COUNT() B) COUNT(column) C) SUM(column) D) AVG(column) Answer: A Explanation: COUNT() counts every row regardless of column nullness; COUNT(col) ignores NULLs. Question 31. What does the expression AVG(salary) return when some salary rows are NULL? A) NULL B) Zero C) The average of non-NULL salaries only D) An error Answer: C Explanation: AVG ignores NULL values and computes the average of the remaining rows. Question 32. Which clause allows you to filter groups after aggregation? A) WHERE B) HAVING C) ORDER BY
Question 35. Which of the following statements will return the third highest salary from the EMP table? A) SELECT salary FROM EMP ORDER BY salary DESC FETCH FIRST 1 ROWS ONLY OFFSET 2; B) SELECT salary FROM EMP ORDER BY salary DESC OFFSET 2 ROWS FETCH NEXT 1 ROW ONLY; C) SELECT MAX(salary) FROM EMP WHERE salary < (SELECT MAX(salary) FROM EMP); D) SELECT salary FROM EMP WHERE ROWNUM = 3 ORDER BY salary DESC; Answer: B Explanation: OFFSET 2 skips the first two highest salaries, FETCH NEXT 1 returns the third. Question 36. Which expression correctly converts a number to a character string with a leading dollar sign? A) TO_CHAR(salary,'$9999') B) TO_CHAR(salary,'$9,999') C) '$' || TO_CHAR(salary) D) CONCAT('$',salary) Answer: C Explanation: Concatenating the literal ‘$’ with TO_CHAR(salary) yields the desired format. Question 37. What is the purpose of the ANSI-SQL standard keyword “AS” in a SELECT statement? A) To create a new table. B) To rename a column or expression in the result set. C) To filter rows. D) To join tables.
Answer: B Explanation: AS provides an alias for a column or expression. Question 38. Which of the following statements will correctly change the case of a column name in the output to “EmployeeName”? A) SELECT employee_name AS EmployeeName FROM employees; B) SELECT employee_name EmployeeName FROM employees; C) SELECT employee_name "EmployeeName" FROM employees; D) All of the above. Answer: D Explanation: All three syntaxes produce the alias EmployeeName; AS is optional, and double quotes preserve case. Question 39. Which clause determines the order in which rows are returned? A) GROUP BY B) HAVING C) ORDER BY D) WHERE Answer: C Explanation: ORDER BY sorts the result set based on specified columns. Question 40. How are NULL values sorted in ascending order by default in Oracle? A) First B) Last C) Randomly placed D) They cause an error
D) WHERE job_id CONTAINS 'SA' Answer: A Explanation: LIKE with a trailing % matches any string that begins with ‘SA’. **Question 44. Which logical operator has higher precedence in Oracle SQL? ** A) OR B) AND C) NOT D) All have equal precedence Answer: C Explanation: NOT is evaluated before AND, which is evaluated before OR. Question 45. What does the expression salary BETWEEN 5000 AND 10000 evaluate to? A) TRUE if salary is exactly 5000 or 10000 only. B) TRUE for salary greater than 5000 and less than 10000. C) TRUE for salary inclusive of both 5000 and 10000. D) FALSE for any salary outside the range. Answer: C Explanation: BETWEEN is inclusive of the lower and upper bound values. Question 46. Which clause would you use to rename a column permanently in the table definition? A) ALTER TABLE … RENAME COLUMN … TO … B) ALTER TABLE … MODIFY COLUMN … AS … C) UPDATE … SET column = new_name;
Answer: A Explanation: ALTER TABLE … RENAME COLUMN changes the column’s name in the table metadata. Question 47. Which of the following is a valid way to create a view named emp_view that selects all columns from EMP? A) CREATE VIEW emp_view AS SELECT * FROM EMP; B) CREATE OR REPLACE emp_view SELECT * FROM EMP; C) CREATE VIEW emp_view SELECT * FROM EMP; D) CREATE VIEW emp_view AS * FROM EMP; Answer: A Explanation: The syntax CREATE VIEW view_name AS SELECT … defines a view. Question 48. How can you make a column in a view read-only? A) Use WITH CHECK OPTION. B) Use WITH READ ONLY. C) Use READ ONLY clause after SELECT. D) Views are always updatable. Answer: B Explanation: Adding WITH READ ONLY prevents DML on the view. Question 49. Which statement correctly creates a primary key constraint on the column emp_id? A) ALTER TABLE employees ADD CONSTRAINT pk_emp PRIMARY KEY (emp_id); B) CREATE PRIMARY KEY ON employees (emp_id);
Answer: A Explanation: DY returns the three-letter abbreviation of the day name. Question 53. Which expression returns the ISO week number for a given date? A) TO_CHAR(date_col,'IW') B) TO_CHAR(date_col,'WW') C) TO_CHAR(date_col,'W') D) TO_CHAR(date_col,'IWK') Answer: A Explanation: ‘IW’ gives the ISO week number (Monday-first week). Question 54. Which of the following statements will correctly change the session’s NLS_DATE_FORMAT to ‘YYYY-MM-DD’? A) ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'; B) SET NLS_DATE_FORMAT = 'YYYY-MM-DD'; C) NLS_DATE_FORMAT = 'YYYY-MM-DD'; D) ALTER SYSTEM SET NLS_DATE_FORMAT = 'YYYY-MM-DD'; Answer: A Explanation: ALTER SESSION modifies NLS parameters for the current session. Question 55. Which operator is used to test for inequality in Oracle SQL? A) <> B) !=
D) Both A and B are valid Answer: D Explanation: Both <> and != are accepted as “not equal” operators. Question 56. Which of the following is the correct syntax to create a sequence named emp_seq starting at 1000 and incrementing by 1? A) CREATE SEQUENCE emp_seq START WITH 1000 INCREMENT BY 1; B) CREATE SEQUENCE emp_seq MINVALUE 1000 STEP 1; C) CREATE SEQUENCE emp_seq BEGIN 1000 NEXT 1; D) CREATE SEQUENCE emp_seq INIT 1000 ADD 1; Answer: A Explanation: START WITH defines the first value; INCREMENT BY defines the step. Question 57. How can you retrieve the next value of a sequence named order_seq in a SELECT statement? A) SELECT order_seq.NEXTVAL FROM dual; B) SELECT NEXTVAL(order_seq) FROM dual; C) SELECT order_seq FROM dual; D) SELECT order_seq.NEXT FROM dual; Answer: A Explanation: .NEXTVAL fetches the next sequence number. Question 58. Which clause can be used to limit the rows returned by a hierarchical query? A) CONNECT BY B) START WITH