MySQL Database Quiz Questions

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

In MySQL, the CAST function can be used to convert a string to an integer.

Q2
True / False

MySQL's CAST function can convert a value to a BOOLEAN data type.

Q3
True / False

In MySQL, the CAST function can be used to convert a date to a string.

Q4
True / False

MySQL allows the CAST function to be used within an ORDER BY clause.

Q5
True / False

MySQL's CAST function can convert a NULL value to any data type without errors.

Q6
True / False

MySQL's CAST function can convert a binary string (BINARY data type) to a non-binary string (CHAR data type).

Q7
True / False

In MySQL, the CAST function cannot be used to convert JSON data to other data types.

Q8
True / False

MySQL’s CAST function can be used to convert a floating-point number to an unsigned integer.

Q9
True / False

Using MySQL's CAST function to convert a string that contains non-numeric characters to an integer will return 0.

Q10
True / False

MySQL's CAST function can be used to convert data types in both SQL queries and stored procedures.

Q11
Single Choice

Which of the following is the correct way to cast a VARCHAR value to an INT in MySQL?

Q12
Single Choice

What will the following SQL code return: SELECT CAST('2024-08-12' AS DATE);?

Q13
Single Choice

How can you cast a DECIMAL value to a CHAR value in MySQL?

Q14
Single Choice

What does the following MySQL query return: SELECT CAST('123.45' AS SIGNED);?

Q15
Single Choice

Consider the following query: SELECT CAST(NULL AS CHAR);. What will it return?

Q16
Single Choice

In MySQL, what will be the result of the following query: SELECT CAST('abc' AS UNSIGNED);?

Q17
Single Choice

Given the query SELECT CAST('2024-08-12 14:30:00' AS TIME);, what will be the output?

Q18
Single Choice

If you run the following MySQL query: SELECT CAST('123abc' AS UNSIGNED);, what will be the result?

Q19
Single Choice

What will the query SELECT CAST(CONCAT('12', '.', '34') AS DECIMAL(4,2)); return in MySQL?

Q20
Single Choice

In a MySQL database, how would the CAST function behave in the following query: SELECT CAST('123.4567' AS DECIMAL(5,2));?

Q21
Multiple Choice

Which SQL query uses CAST to convert a string '2024-08-25' into a DATE type?

SQL Code
SELECT CAST('2024-08-25' AS DATE) AS formatted_date;
Q22
Multiple Choice

Identify the SQL query that uses CAST to convert a string '123.45' into a DECIMAL type.

SQL Code
SELECT CAST('123.45' AS DECIMAL(5,2)) AS decimal_value;
Q23
Multiple Choice

Which SQL query uses CAST to convert a DATE column to a VARCHAR format?

SQL Code
SELECT CAST(order_date AS CHAR) AS order_date_str
FROM orders;
Q24
Multiple Choice

Determine the SQL query that uses CAST to convert a TIMESTAMP into a DATETIME type.

SQL Code
SELECT CAST(created_at AS DATETIME) AS created_at_dt
FROM events;
Q25
Multiple Choice

Which SQL query uses CAST to convert an integer value '100' into a CHAR type?

SQL Code
SELECT CAST(100 AS CHAR) AS char_value;
Q26
Multiple Choice

Which SQL query uses CAST to ensure a column 'price' is treated as DECIMAL during a SUM operation?

SQL Code
SELECT SUM(CAST(price AS DECIMAL(10,2))) AS total_price
FROM sales;
Q27
Multiple Choice

Identify the SQL query that uses CAST to convert a VARCHAR column 'quantity' to an INTEGER for comparison.

SQL Code
SELECT * FROM inventory
WHERE CAST(quantity AS SIGNED) > 100;
Q28
Multiple Choice

Which SQL query uses CAST to format a numeric 'balance' column to display with two decimal places?

SQL Code
SELECT CAST(balance AS DECIMAL(10,2)) AS formatted_balance
FROM accounts;
Q29
Multiple Choice

Determine the SQL query that uses CAST to convert a binary string '101010' to an INTEGER.

SQL Code
SELECT CAST('101010' AS UNSIGNED) AS integer_value;
Q30
Multiple Choice

Which SQL query uses CAST to convert a JSON column 'data' to a VARCHAR for easy text manipulation?

SQL Code
SELECT CAST(data AS CHAR) AS data_str
FROM logs;