Create New Post

MYSQL MCQs - 9

  1. What is the purpose of the IFNULL() function in MySQL?

    • A) To check if a value is null
    • B) To return the first non-null value in a list of expressions
    • C) To concatenate values from multiple rows into a single string
    • D) To return the current date and time

    Answer: B) To return the first non-null value in a list of expressions

  2. Which SQL command is used to create a primary key constraint in MySQL?

    • A) ADD PRIMARY KEY
    • B) CREATE PRIMARY KEY
    • C) PRIMARY KEY
    • D) SET PRIMARY KEY

    Answer: A) ADD PRIMARY KEY

  3. What is the purpose of the BETWEEN operator in MySQL?

    • A) To check if a value exists in a specified range
    • B) To specify the starting row from which to retrieve rows in the result set
    • C) To concatenate values from multiple rows into a single string
    • D) To return the first non-null value in a list of expressions

    Answer: A) To check if a value exists in a specified range

  4. Which SQL function is used to return the difference between two dates in MySQL?

    • A) DATEDIFF()
    • B) DATE_DIFF()
    • C) DIFFERENCE()
    • D) DATE_DIFFERENCE()

    Answer: A) DATEDIFF()

  5. What is the purpose of the CONCAT() function in MySQL?

    • A) To concatenate values from multiple rows into a single string
    • B) To concatenate values with a specified separator
    • C) To return the first non-null value in a list of expressions
    • D) To return the current date and time

    Answer: A) To concatenate values from multiple rows into a single string

  6. Which SQL command is used to create a unique constraint in MySQL?

    • A) ADD UNIQUE
    • B) CREATE UNIQUE
    • C) UNIQUE
    • D) SET UNIQUE

    Answer: A) ADD UNIQUE

  7. What is the purpose of the SUM() function in MySQL?

    • A) To calculate the average value of a numeric column
    • B) To return the number of rows in a table
    • C) To calculate the total value of a numeric column
    • D) To concatenate values from multiple rows into a single string

    Answer: C) To calculate the total value of a numeric column

  8. Which SQL function is used to return the current year in MySQL?

    • A) YEAR()
    • B) CURRENT_YEAR()
    • C) GETYEAR()
    • D) CURYEAR()

    Answer: A) YEAR()

  9. What is the purpose of the MAX() function in MySQL?

    • A) To return the maximum value of a column
    • B) To return the minimum value of a column
    • C) To return the average value of a column
    • D) To return the total value of a column

    Answer: A) To return the maximum value of a column

  10. Which SQL command is used to delete a unique constraint from a table in MySQL?

    • A) DELETE UNIQUE
    • B) REMOVE UNIQUE
    • C) DROP UNIQUE
    • D) ERASE UNIQUE

    Answer: C) DROP UNIQUE

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

92242