Create New Post

MYSQL MCQs - 8

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

    • A) To calculate the difference between two dates
    • B) To return the current date and time
    • C) To format a date value according to a specified format
    • D) To extract a part of a date value

    Answer: C) To format a date value according to a specified format

  2. Which SQL command is used to grant all privileges to a user in MySQL?

    • A) GRANT ALL PRIVILEGES
    • B) GRANT PRIVILEGES
    • C) GRANT ALL
    • D) GRANT FULL PRIVILEGES

    Answer: A) GRANT ALL PRIVILEGES

  3. What is the purpose of the DISTINCT keyword in conjunction with the COUNT() function in MySQL?

    • A) To return the number of distinct values in a column
    • B) To return the number of rows in a table
    • C) To return the number of non-null values in a column
    • D) To return the number of unique combinations of values in multiple columns

    Answer: A) To return the number of distinct values in a column

  4. Which SQL function is used to return the current time in MySQL?

    • A) CURRENT_TIME()
    • B) NOW()
    • C) GETTIME()
    • D) CURTIME()

    Answer: A) CURRENT_TIME()

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

    • A) To return the length of a string in bytes
    • B) To return the length of a string in characters
    • C) To return the length of a string in bits
    • D) To return the length of a string in words

    Answer: B) To return the length of a string in characters

  6. Which SQL command is used to rename a table in MySQL?

    • A) RENAME TABLE
    • B) ALTER TABLE
    • C) MODIFY TABLE
    • D) CHANGE TABLE

    Answer: A) RENAME TABLE

  7. What is the purpose of the ORDER BY clause in conjunction with the GROUP_CONCAT() function in MySQL?

    • A) To order the result set by a specified column
    • B) To group rows together based on a specified column
    • C) To concatenate values from multiple rows into a single string
    • D) To filter rows based on a specified condition

    Answer: A) To order the result set by a specified column

  8. Which SQL function is used to return the number of days between two dates in MySQL?

    • A) DATEDIFF()
    • B) DAYDIFF()
    • C) DAYS()
    • D) DATE_DAYS()

    Answer: A) DATEDIFF()

  9. What is the purpose of the ALL keyword in conjunction with the IN operator in MySQL?

    • A) To specify that all values in a subquery must match
    • B) To specify that any value in a subquery must match
    • C) To specify that none of the values in a subquery must match
    • D) To specify that some of the values in a subquery must match

    Answer: A) To specify that all values in a subquery must match

  10. Which SQL command is used to create an index on multiple columns in MySQL?

    • A) CREATE INDEX
    • B) ADD INDEX
    • C) INDEX TABLE
    • D) ALTER INDEX

    Answer: A) CREATE INDEX

Comments

Leave a Reply

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

81810