Oracle_test4

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Sudha_test
S
Sudha_test
Community Contributor
Quizzes Created: 12 | Total Attempts: 36,472
Questions: 15 | Attempts: 1,302

SettingsSettingsSettings
Measurement Quizzes & Trivia

This test used to rate your Oracle skills


Questions and Answers
  • 1. 

    Which SELECT statement will the result 'ello world' from the string 'Hello World'?

    • A.

      SELECT SUBSTR ('Hello',) FROM dual;

    • B.

      SELECT INITCAP (TRIM ('Hello World',1,1) FROM dual;

    • C.

      SELECT LOWER (SUBSTR ('Hello World',1,1) FROM dual;

    • D.

      SELECT LOWER (SUBSTR ('Hello World',2,1) FROM dual;

    • E.

      SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual;

    Correct Answer
    E. SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual;
    Explanation
    The correct answer is SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual; This query uses the TRIM function to remove the letter 'H' from the string 'Hello World', and then applies the LOWER function to convert the remaining string to lowercase. The result is 'ello world'.

    Rate this question:

  • 2. 

    Which four statements correctly describe functions that are available in SQL?

    • A.

      INSTR returns the numeric position of a named character.

    • B.

      NVL2 returns the first non-null expression in the expression list.

    • C.

      TRUNCATE rounds the column, expression, or value to n decimal places

    • D.

      DECODE translates an expression after comparing it to each search value.

    • E.

      TRIM trims the heading of trailing characters (or both) from a character string.

    Correct Answer(s)
    A. INSTR returns the numeric position of a named character.
    E. TRIM trims the heading of trailing characters (or both) from a character string.
    Explanation
    INSTR is a function in SQL that returns the numeric position of a named character within a string. TRIM is another function that trims the heading or trailing characters (or both) from a character string. Both of these statements correctly describe the functions available in SQL.

    Rate this question:

  • 3. 

     Which two statements are true regarding the ORDER BY clause?

    • A.

      The sort is in ascending by order by default.

    • B.

      The sort is in descending order by default.

    • C.

      The ORDER BY clause must precede the WHERE clause.

    • D.

      The ORDER BY clause is executed on the client side.

    • E.

      The ORDER BY clause comes last in the SELECT statement.

    Correct Answer(s)
    A. The sort is in ascending by order by default.
    E. The ORDER BY clause comes last in the SELECT statement.
    Explanation
    The first statement is true because if the ORDER BY clause does not specify the sort order as ascending or descending, it will default to ascending order. The fifth statement is also true because the ORDER BY clause is typically placed at the end of the SELECT statement to specify the sorting criteria for the result set.

    Rate this question:

  • 4. 

    Which SQL statement generates the alias Annual Salary for the calculated column SALARY*12? 

    • A.

      SELECT ename, salary*12 'Annual Salary' FROM employees;

    • B.

      SELECT ename, salary*12 "Annual Salary" FROM employees;

    • C.

      SELECT ename, salary*12 AS Annual Salary FROM employees;

    • D.

      SELECT ename, salary*12 AS INITCAP("ANNUAL SALARY") FROM employees

    Correct Answer
    B. SELECT ename, salary*12 "Annual Salary" FROM employees;
    Explanation
    The correct answer is "SELECT ename, salary*12 'Annual Salary' FROM employees;". This statement generates the alias "Annual Salary" for the calculated column SALARY*12 by using single quotes around the alias name.

    Rate this question:

  • 5. 

    You need to display the last names of those employees who have the letter "A" as the second character in their names. Which SQL statement displays the required results?

    • A.

      SELECT last_name FROM EMP WHERE last_ name LIKE '_A%';

    • B.

      SELECT last_name FROM EMP WHERE last name ='*A%'

    • C.

      SELECT last_name FROM EMP WHERE last name ='_A%';

    • D.

      SELECT last_name FROM EMP WHERE last name LIKE '*A%'

    Correct Answer
    C. SELECT last_name FROM EMP WHERE last name ='_A%';
    Explanation
    The correct answer is "SELECT last_name FROM EMP WHERE last name ='_A%';". This statement uses the LIKE operator with the wildcard "_" to match any single character, followed by "A%" to match any string starting with "A". Therefore, it will display the last names of employees who have the letter "A" as the second character in their names.

    Rate this question:

  • 6. 

    Which SELECT statement should you use to extract the year from the system date and display it in the format "1998"?

    • A.

      SELECT TO_CHAR(SYSDATE,'yyyy') FROM dual;

    • B.

      SELECT TO_DATE(SYSDATE,'yyyy') FROM dual;

    • C.

      SELECT DECODE(SUBSTR(SYSDATE, 8), 'YYYY') FROM dual;

    • D.

      SELECT DECODE(SUBSTR(SYSDATE, 8), 'year') FROM dual;

    • E.

      SELECT TO_CHAR(SUBSTR(SYSDATE, 8,2),'yyyy') FROM dual;

    Correct Answer
    A. SELECT TO_CHAR(SYSDATE,'yyyy') FROM dual;
    Explanation
    The correct answer is SELECT TO_CHAR(SYSDATE,'yyyy') FROM dual; This statement uses the TO_CHAR function to convert the system date (SYSDATE) into a string in the format 'yyyy', which represents the year. The FROM dual clause is used to select from a dummy table in Oracle.

    Rate this question:

  • 7. 

    Examine the description of the EMPLOYEES table: EMP_ID NUMBER(4) NOT NULL LAST_NAME VARCHAR2(30) NOT NULL FIRST_NAME VARCHAR2(30) DEPT_ID NUMBER(2) Which statement produces the number of different departments that have employees with last name Smith?

    • A.

      SELECT COUNT (*) FROM employees WHERE last _name='smith';

    • B.

      SELECT COUNT (dept_id) FROM employees WHERE last _name='smith';

    • C.

      SELECT DISTINCT (COUNT (dept_id) FROM employees WHERE last _name='smith';

    • D.

      SELECT COUNT (DISTINCT dept_id) FROM employees WHERE last _name='smith';

    • E.

      SELECT UNIQE (dept_id) FROM employees WHERE last _name='smith';

    Correct Answer
    D. SELECT COUNT (DISTINCT dept_id) FROM employees WHERE last _name='smith';
    Explanation
    The correct answer is SELECT COUNT (DISTINCT dept_id) FROM employees WHERE last _name='smith'. This statement calculates the number of different departments that have employees with the last name Smith. It uses the COUNT function to count the number of distinct (unique) department IDs where the last name is Smith.

    Rate this question:

  • 8. 

    Evaluate this SQL statement: SELECT ename, sal, 12* sal+100 FROM emp; The SAL column stores the monthly salary of the employee. Which change must be made to the above syntax to calculate the annual compensation as "monthly salary plus a monthly bonus of $100, multiplied by 12"?

    • A.

      No change is required to achieve the desired results.

    • B.

      SELECT ename, sal, 12* (sal+100) FROM emp;

    • C.

      SELECT ename, sal, (12* sal)+100 FROM emp;

    • D.

      SELECT ename, sal +100,*12 FROM emp;

    Correct Answer
    B. SELECT ename, sal, 12* (sal+100) FROM emp;
    Explanation
    The given SQL statement is calculating the annual compensation by multiplying the monthly salary by 12 and adding 100. To achieve the desired result of calculating the annual compensation as "monthly salary plus a monthly bonus of $100, multiplied by 12", the parentheses should be added around "sal+100" in the calculation. Therefore, the correct change that must be made to the above syntax is: SELECT ename, sal, 12* (sal+100) FROM emp.

    Rate this question:

  • 9. 

    The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(4) LAST_NAME VARCHAR2 (25) JOB_ID VARCHAR2(10) You want to search for strings that contain 'SA_' in the JOB_ID column. Which SQL statement do you use?

    • A.

      SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA\_%'ESCAPE'\';

    • B.

      SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_';

    • C.

      SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_'ESCAPE'\';

    • D.

      SELECT employee_id, last_name, job_id FROM employees WHERE job_id '%SA_';

    Correct Answer
    A. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA\_%'ESCAPE'\';
    Explanation
    The correct answer is "SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE
    '%SA\_%'ESCAPE'\';"

    This SQL statement uses the LIKE operator with the wildcard '%' to search for strings in the JOB_ID column that contain 'SA_' as a substring. The backslash '\' is used as an escape character to treat the underscore '_' as a literal character rather than a wildcard.

    Rate this question:

  • 10. 

    The CUSTOMERS table has these columns: CUSTOMER_ID NUMBER(4) NOT NULL CUSTOMER_NAME VARCHAR2(100) NOT NULL CUSTOMER_ADDRESS VARCHAR2(150) CUSTOMER_pHONE VARCHAR2(20) You need to produce output that states "Dear Customer customer_name, ". The customer_name data values come from the CUSTOMER_NAME column in the CUSTOMERS table. Which statement produces this output?

    • A.

      SELECT dear customer, customer_name, FROM customer;

    • B.

      SELECT "Dear Customer", customer_name, ||',' FROM customer;

    • C.

      SELECT 'Dear Customer' || customer_name ',' FROM customer;

    • D.

      SELECT 'Dear Customer' || customer_name || ',' FROM customer;

    • E.

      SELECT "Dear Customer" || customer_name || "," FROM customer;

    Correct Answer
    D. SELECT 'Dear Customer' || customer_name || ',' FROM customer;
    Explanation
    The correct answer is "SELECT 'Dear Customer' || customer_name || ',' FROM customer;". This statement concatenates the string 'Dear Customer' with the values from the customer_name column in the CUSTOMERS table, and adds a comma at the end. This will produce the desired output of "Dear Customer customer_name," for each row in the table.

    Rate this question:

  • 11. 

    The CUSTOMERS table has these columns: CUSTOMER_ID NUMBER(4) NOT NULL CUSTOMER_NAME VARCHAR2(100) NOT NULL STREET_ADDRESS VARCHAR2(150) CITY_ADDRESS VARCHAR2(50) STATE_ADDRESS VARCHAR2(50) PROVINCE_ADDRESS VARCHAR2(50) COUNTRY_ADDRESS VARCHAR2(50) POSTAL_CODE VARCHAR2(12) CUSTOMER_pHONE VARCHAR2(20) A promotional sale is being advertised to the customers in France. Which WHERE clause identifies customers that are located in France?

    • A.

      WHERE lower(country_address) = "france"

    • B.

      WHERE lower(country_address) = 'france'

    • C.

      WHERE lower(country_address) IS 'france'

    • D.

      WHERE lower(country_address) = '%france%'

    • E.

      WHERE lower(country_address) LIKE %france%

    Correct Answer
    B. WHERE lower(country_address) = 'france'
    Explanation
    The correct answer is "WHERE lower(country_address) = 'france'". This WHERE clause is checking if the country_address column is equal to the string 'france' after converting it to lowercase. This will identify customers that are located in France.

    Rate this question:

  • 12. 

    The PRODUCTS table has these columns: PRODUCT_ID NUMBER(4) PRODUCT_NAME VARCHAR2(45) PRICE NUMBER(8,2) Evaluate this SQL statement: SELECT * FROM PRODUCTS ORDER BY price, product _ name; What is true about the SQL statement?

    • A.

      The results are not sorted.

    • B.

      The results are sorted numerically.

    • C.

      The results are sorted alphabetically.

    • D.

      The results are sorted numerically and then alphabetically.

    Correct Answer
    D. The results are sorted numerically and then alpHabetically.
    Explanation
    The SQL statement will sort the results first by the "price" column in numerical order, and then by the "product_name" column in alphabetical order.

    Rate this question:

  • 13. 

    Evaluate the SQL statement: SELECT LPAD (salary,10,*) FROM EMP WHERE EMP _ ID = 1001; If the employee with the EMP_ID 1001 has a salary of 17000, what is displayed?

    • A.

      17000.00

    • B.

      17000*****

    • C.

      ****17000

    • D.

      **17000.00

    • E.

      An error statement

    Correct Answer
    E. An error statement
    Explanation
    The SQL statement is attempting to use the LPAD function to left pad the salary value with asterisks (*) to a total length of 10 characters. However, the LPAD function expects the second argument to be a number, not a string. Therefore, the SQL statement will result in an error.

    Rate this question:

  • 14. 

    What will the following expression return when the PRICE is NULL? POWER((NVL(PRICE, 0) / NVL(PRICE, 1)) * 5, 2)  

    • A.

      25

    • B.

      5

    • C.

      2

    • D.

      1

    • E.

      None of the above

    Correct Answer
    D. 1
    Explanation
    The expression calculates the result of (PRICE / PRICE) * 5 and then raises it to the power of 2. Since PRICE is NULL, the NVL function replaces it with 0 in the numerator and 1 in the denominator. Therefore, the expression becomes (0 / 1) * 5, which equals 0. When 0 is raised to the power of 2, the result is still 0. Hence, the correct answer is 1.

    Rate this question:

  • 15. 

    What does this expression produce? Type your answer in as a response. SUBSTR(  TRANSLATE(  REPLACE('This is a string', ' ', '')    , 'ia', 'AI'), 5, 3)

    Correct Answer
    AsI
    Explanation
    The given expression starts by removing all spaces from the string 'This is a string' using the REPLACE function. The TRANSLATE function then replaces all occurrences of 'ia' with 'AI'. Finally, the SUBSTR function extracts a substring starting from the 5th character with a length of 3. Therefore, the expression produces the output 'AsI'.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 04, 2010
    Quiz Created by
    Sudha_test
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.