Create New Post

MYSQL MCQs - 7

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

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

    Answer: A) To return the number of rows in a table

  2. Which SQL command is used to add a foreign key constraint to a table in MySQL?

    • A) ADD FOREIGN KEY
    • B) CREATE FOREIGN KEY
    • C) ALTER FOREIGN KEY
    • D) SET FOREIGN KEY

    Answer: B) CREATE FOREIGN KEY

  3. What is the purpose of the UNIQUE constraint in MySQL?

    • A) To ensure that each row in a table is unique
    • B) To ensure that a column does not contain null values
    • C) To specify the default value for a column
    • D) To specify the primary key for a table

    Answer: A) To ensure that each row in a table is unique

  4. Which SQL function is used to return the lowercase version of a string in MySQL?

    • A) LOWER()
    • B) LCASE()
    • C) TOLOWER()
    • D) CONVERT()

    Answer: A) LOWER()

  5. What is the purpose of the CASCADE option in a foreign key constraint in MySQL?

    • A) To specify the action to perform when a foreign key constraint is violated
    • B) To specify the action to perform when a primary key constraint is violated
    • C) To specify the action to perform when a column is updated
    • D) To specify the action to perform when a column is deleted

    Answer: A) To specify the action to perform when a foreign key constraint is violated

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

    • A) CREATE VIEW
    • B) ADD VIEW
    • C) MAKE VIEW
    • D) INSERT VIEW

    Answer: A) CREATE VIEW

  7. What is the purpose of the EXISTS operator in MySQL?

    • A) To check if a value exists in a specified range
    • B) To check if a subquery returns any rows
    • C) To filter rows based on a specified condition
    • D) To specify the columns to retrieve in the result set

    Answer: B) To check if a subquery returns any rows

  8. Which SQL function is used to return the uppercase version of a string in MySQL?

    • A) UPPER()
    • B) UCASE()
    • C) TOUPPER()
    • D) CONVERT()

    Answer: A) UPPER()

  9. What is the purpose of the AS keyword in MySQL?

    • A) To specify the table to perform the operation on
    • B) To specify the columns to retrieve in the result set
    • C) To rename a column or table in the result set
    • D) To filter rows based on a specified condition

    Answer: C) To rename a column or table in the result set

  10. Which SQL command is used to remove a foreign key constraint from a table in MySQL?

    • A) DELETE FOREIGN KEY
    • B) REMOVE FOREIGN KEY
    • C) DROP FOREIGN KEY
    • D) ERASE FOREIGN KEY

    Answer: C) DROP FOREIGN KEY

Comments

Leave a Reply

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

84369