Oracle Database Quiz Questions

Course Name:Oracle
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:CAST
Current Quiz Count:30
Progress
0%
Q1
True / False

In Oracle, the CAST function is used to convert one data type to another.

Q2
True / False

The CAST function in Oracle can convert a string to a number.

Q3
True / False

In Oracle, the CAST function can only be used to convert numeric data types.

Q4
True / False

The CAST function in Oracle can be used to convert a DATE value to a VARCHAR2 value.

Q5
True / False

In Oracle, the CAST function can be used to convert a BLOB to a CLOB.

Q6
True / False

The CAST function in Oracle can be used in the SELECT clause to change the data type of columns in the result set.

Q7
True / False

In Oracle, the CAST function can be used to convert a TIMESTAMP value to a DATE value.

Q8
True / False

The CAST function in Oracle can convert an INTERVAL type to a NUMBER type.

Q9
True / False

In Oracle, using the CAST function to convert data types can sometimes result in data loss if the conversion is not compatible.

Q10
True / False

The Oracle Certified Professional (OCP) exam includes knowledge on using the CAST function effectively, understanding its syntax, and handling potential conversion errors in SQL queries.

Q11
Single Choice

What is the primary purpose of the CAST function in Oracle SQL?

Q12
Single Choice

Which of the following is a correct usage of the CAST function to convert a string to a number in Oracle SQL?

Q13
Single Choice

What will be the result of the following Oracle SQL query?

SQL Code
SELECT CAST(123 AS VARCHAR2(5)) FROM dual;
Q14
Single Choice

Consider the following Oracle SQL query:What does this query do?

SQL Code
SELECT CAST('2024-08-21' AS DATE) FROM dual;
Q15
Single Choice

Which Oracle SQL query correctly converts a string in the format 'YYYY-MM-DD' to a date?

Q16
Single Choice

Given the Oracle SQL query:What will be the result?

SQL Code
SELECT CAST(ROUND(123.456, 1) AS VARCHAR2(6)) FROM dual;
Q17
Single Choice

What will be the result of the following Oracle SQL query?

SQL Code
SELECT CAST(SUBSTR('Oracle 123', 8, 3) AS NUMBER) FROM dual;
Q18
Single Choice

Consider this Oracle SQL query:What does the query return?

SQL Code
SELECT CAST(SYSDATE AS TIMESTAMP) FROM dual;
Q19
Single Choice

Which of the following Oracle SQL queries correctly casts a TIMESTAMP to a DATE?

Q20
Single Choice

What is the result of the following Oracle SQL query?

SQL Code
SELECT CAST(CAST('100.99' AS NUMBER) AS VARCHAR2(10)) FROM dual;
Q21
Multiple Choice

Which SQL code snippet demonstrates converting a string to a number using the `CAST` function in Oracle?

SQL Code
SELECT employee_id, CAST(salary AS NUMBER) AS salary_num
FROM employees
WHERE CAST('12345' AS NUMBER) > 10000;
Q22
Multiple Choice

Which SQL code snippet demonstrates converting a date to a string using the `CAST` function in Oracle?

SQL Code
SELECT employee_id, hire_date, CAST(hire_date AS VARCHAR2(20)) AS hire_date_str
FROM employees
WHERE CAST(hire_date AS VARCHAR2(20)) = '01-JAN-2023';
Q23
Multiple Choice

Which SQL code snippet demonstrates converting a number to a string using the `CAST` function in Oracle?

SQL Code
SELECT employee_id, salary, CAST(salary AS VARCHAR2(10)) AS salary_str
FROM employees
WHERE CAST(salary AS VARCHAR2(10)) LIKE '5%';
Q24
Multiple Choice

Which SQL code snippet demonstrates converting a timestamp to a date using the `CAST` function in Oracle?

SQL Code
SELECT employee_id, CAST(hire_date AS DATE) AS hire_date_only
FROM employees
WHERE CAST(hire_date AS DATE) = TO_DATE('01-JAN-2023', 'DD-MON-YYYY');
Q25
Multiple Choice

Which SQL code snippet demonstrates converting a string to a date using the `CAST` function in Oracle?

SQL Code
SELECT employee_id, CAST('2023-01-01' AS DATE) AS hire_date
FROM employees
WHERE CAST('2023-01-01' AS DATE) > TO_DATE('01-JAN-2022', 'DD-MON-YYYY');
Q26
Multiple Choice

Which SQL code snippet demonstrates advanced use of the `CAST` function to convert a number to a character and concatenate it with a string in Oracle?

SQL Code
SELECT employee_id, first_name || CAST(salary AS VARCHAR2(10)) AS employee_info
FROM employees
WHERE CAST(salary AS VARCHAR2(10)) LIKE '5%';
Q27
Multiple Choice

Which SQL code snippet demonstrates advanced use of the `CAST` function to convert a date to a character and perform a string comparison in Oracle?

SQL Code
SELECT employee_id, CAST(hire_date AS VARCHAR2(20)) AS hire_date_str
FROM employees
WHERE CAST(hire_date AS VARCHAR2(20)) = '01-JAN-2023';
Q28
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the `CAST` function to convert a character string to a timestamp in Oracle?

SQL Code
SELECT employee_id, first_name, CAST('2023-01-01 12:00:00' AS TIMESTAMP) AS hire_timestamp
FROM employees
WHERE CAST('2023-01-01 12:00:00' AS TIMESTAMP) > TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS');
Q29
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the `CAST` function to convert a number to a binary_float in Oracle?

SQL Code
SELECT employee_id, salary, CAST(salary AS BINARY_FLOAT) AS salary_float
FROM employees
WHERE CAST(salary AS BINARY_FLOAT) > 5000.00;
Q30
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the `CAST` function to convert a string to a blob in Oracle?

SQL Code
SELECT employee_id, CAST('SampleData' AS BLOB) AS data_blob
FROM employees
WHERE CAST('SampleData' AS BLOB) IS NOT NULL;