MySQL

MySQL is an open-source relational database management system (RDBMS) that uses Structured Query Language (SQL) for managing and manipulating databases. It is widely used for storing and retrieving data in various applications.

  1. MySQL is freely available and is open source
    a) True ✅
    b) False
    c) Not sure
    d) Private

  2. What represents a ‘tuple’ in a relational database?
    a) Table
    b) Row ✅
    c) Column
    d) Object

  3. How is communication established with MySQL?
    a) SQL ✅
    b) Network calls
    c) A programming language like C++
    d) APIs

  4. The MySQL server used in its client/server architecture is _______________
    a) mysqla
    b) mysqlb
    c) mysqlc
    d) mysqld ✅

  5. Which of the following clauses is used to display information that matches a given pattern?
    a) LIKE ✅
    b) WHERE
    c) IS
    d) SAME

  6. What command is used to delete all records from a table without deleting the table itself?
    a) TRUNCATE
    b) DROP
    c) DELETE
    d) REMOVE

  7. Which of the following SQL statements is used to fetch data from a database?
    a) SELECT
    b) FETCH
    c) GET
    d) RETRIEVE

  8. Which SQL clause is used to sort the result set?
    a) ORDER BY
    b) SORT
    c) GROUP BY
    d) ARRANGE

  9. Which of the following is used to create a new database in MySQL?
    a) CREATE DATABASE
    b) NEW DATABASE
    c) MAKE DATABASE
    d) ADD DATABASE

  10. Which of the following is the correct way to use the SELECT statement to retrieve data from the “students” table where the student’s name is “John”?
    a) SELECT * FROM students WHERE name = ‘John’;
    b) SELECT * FROM students WHERE name = ‘John’
    c) SELECT name FROM students WHERE name = ‘John’;
    d) SELECT students WHERE name = ‘John’;

  11. Which of the following statements is true about indexes in MySQL?
    a) Indexes are automatically created by MySQL.
    b) Indexes help improve the performance of queries.
    c) Indexes reduce the space used by the database.
    d) Indexes help improve the performance of queries.

  12. Which of the following is used to retrieve a specific range of rows in MySQL?
    a) LIMIT ✅
    b) RANGE
    c) FETCH
    d) RESTRICT

  13. What does the SELECT DISTINCT statement do in SQL?
    a) Retrieves only one record from the database.
    b) Retrieves only unique records.
    c) Sorts the records in ascending order.
    d) Limits the number of records returned.

  14. Which of the following MySQL data types is used to store a variable-length string?
    a) VARCHAR ✅
    b) TEXT
    c) CHAR
    d) BLOB

  15. Which SQL command is used to modify the existing data in a table?
    a) UPDATE
    b) MODIFY
    c) CHANGE
    d) ALTER

  16. Which of the following is true about the SQL INSERT INTO statement?
    a) It is used to retrieve records from a table.
    b) It is used to delete records from a table.
    c) It is used to add new records to a table.
    d) It is used to modify existing records in a table.

  17. Which of the following SQL clauses is used to combine rows from two or more tables based on a related column?
    a) UNION
    b) JOIN
    c) COMBINE
    d) MERGE

  18. What is the purpose of the WHERE clause in SQL?
    a) To sort the records
    b) To filter the records based on a condition.
    c) To group the records
    d) To order the records

  19. What command is used to modify the structure of an existing database table?
    a) ALTER TABLE
    b) MODIFY TABLE
    c) CHANGE TABLE
    d) UPDATE TABLE

  20. What does the SQL SELECT statement return?
    a) The entire database
    b) A table
    c) A result set based on the query.
    d) A single record

  1. Which SQL keyword is used to retrieve records from multiple tables?
    a) JOIN
    b) COMBINE
    c) UNION
    d) MERGE

  2. Which of the following is the correct way to add a primary key to an existing table in MySQL?
    a) ALTER TABLE table_name ADD PRIMARY KEY (column_name);
    b) ALTER TABLE table_name ADD PRIMARY KEY (column_name);
    c) MODIFY TABLE table_name ADD PRIMARY KEY (column_name);
    d) CHANGE TABLE table_name ADD PRIMARY KEY (column_name);

  3. Which function is used to count the number of rows in a table?
    a) COUNT()
    b) SUM()
    c) AVG()
    d) ROWS()

  4. Which SQL clause is used to remove duplicate rows from the result set?
    a) DISTINCT
    b) UNIQUE
    c) DIFFERENT
    d) NO_DUPLICATES

  5. Which of the following operators is used to search for a specified pattern in a column?
    a) LIKE
    b) IN
    c) BETWEEN
    d) EQUALS

  6. Which of the following statements is used to delete a table from a database in MySQL?
    a) DROP TABLE
    b) DELETE TABLE
    c) REMOVE TABLE
    d) CLEAR TABLE

  7. Which keyword is used to sort the result set in descending order in SQL?
    a) DESC
    b) SORT DESC
    c) ORDER DESC
    d) REVERSE

  8. Which of the following SQL functions is used to return the maximum value in a column?
    a) MIN()
    b) MAX()
    c) AVG()
    d) SUM()

  9. Which of the following commands is used to create an index on a table in MySQL?
    a) CREATE INDEX
    b) ADD INDEX
    c) NEW INDEX
    d) MAKE INDEX

  10. Which SQL clause is used to group rows that have the same values in specified columns?
    a) GROUP BY
    b) ORDER BY
    c) SORT BY
    d) AGGREGATE

  11. Which of the following statements is used to update data in a table?
    a) UPDATE
    b) MODIFY
    c) CHANGE
    d) ALTER

  12. Which operator is used to test for NULL values in SQL?
    a) IS NULL
    b) NULL TEST
    c) IS EMPTY
    d) NULL CHECK

  13. Which of the following is used to display the current date and time in MySQL?
    a) NOW()
    b) GETDATE()
    c) CURDATE()
    d) CURRENT_DATE()

  14. Which SQL statement is used to add a new row to a table?
    a) INSERT INTO
    b) ADD INTO
    c) INSERT VALUES
    d) NEW RECORD

  15. Which of the following is used to set a condition to limit the rows returned in a SQL query?
    a) WHERE
    b) HAVING
    c) IF
    d) LIMIT

  16. Which of the following is used to remove a column from an existing table?
    a) ALTER TABLE table_name DROP COLUMN column_name;
    b) DELETE COLUMN column_name;
    c) REMOVE COLUMN column_name;
    d) DROP COLUMN column_name FROM table_name;

  17. Which function is used to get the length of a string in SQL?
    a) LENGTH()
    b) STRLEN()
    c) CHAR_LENGTH()
    d) SIZE()

  18. Which keyword is used to retrieve data from two or more tables in SQL?
    a) JOIN
    b) UNION
    c) COMBINE
    d) INTERSECT

  19. Which SQL clause is used to specify the sorting order of records?
    a) ORDER BY
    b) SORT BY
    c) GROUP BY
    d) ARRANGE BY

  20. Which of the following is the correct way to select only unique values in a column?
    a) SELECT DISTINCT column_name FROM table_name;
    b) SELECT UNIQUE column_name FROM table_name;
    c) SELECT DISTINCT column_name FROM table_name;
    d) SELECT DISTINCT FROM table_name column_name;

  1. Which SQL keyword is used to sort the result set in ascending order?
    a) ASC
    b) DESC
    c) SORT
    d) ORDER

  2. What does the SQL statement SELECT COUNT(*) FROM table_name; do?
    a) It selects all columns from the table.
    b) It counts the number of rows in the table.
    c) It counts the distinct rows in the table.
    d) It counts the total number of columns in the table.

  3. Which SQL clause is used to filter records after grouping them?
    a) HAVING
    b) WHERE
    c) GROUP
    d) FILTER

  4. Which of the following is used to combine the results of two SELECT statements in SQL?
    a) UNION
    b) JOIN
    c) INTERSECT
    d) COMBINE

  5. Which keyword is used to limit the number of rows returned in a SQL query?
    a) LIMIT
    b) TOP
    c) ROWS
    d) RESTRICT

  6. Which of the following SQL statements is used to remove a row from a table?
    a) DELETE
    b) DROP
    c) REMOVE
    d) TRUNCATE

  7. Which SQL clause is used to specify the column in which you want to perform an aggregate function?
    a) GROUP BY
    b) ORDER BY
    c) HAVING
    d) SELECT

  8. Which SQL statement is used to change an existing column in a table?
    a) ALTER TABLE
    b) MODIFY COLUMN
    c) CHANGE COLUMN
    d) UPDATE COLUMN

  9. Which SQL function is used to return the current date in MySQL?
    a) CURDATE()
    b) NOW()
    c) GETDATE()
    d) CURRENT_DATE()

  10. Which clause is used to retrieve data from multiple tables based on a relationship between them?
    a) JOIN
    b) UNION
    c) INTERSECT
    d) MERGE

  11. Which SQL keyword is used to find records that match a specific pattern?
    a) MATCH
    b) LIKE
    c) CONTAINS
    d) EQUALS

  12. Which statement is used to modify data in a table?
    a) UPDATE
    b) MODIFY
    c) CHANGE
    d) ALTER

  13. Which SQL keyword is used to return only distinct (unique) values in a query?
    a) DISTINCT
    b) UNIQUE
    c) NO_DUPLICATES
    d) DIFFERENT

  14. Which of the following SQL functions is used to find the average value of a column?
    a) SUM()
    b) AVG()
    c) COUNT()
    d) MAX()

  15. Which SQL clause is used to define the condition for the rows to be included in a result set?
    a) WHERE
    b) HAVING
    c) GROUP BY
    d) FILTER

  16. What does the ORDER BY clause do in SQL?
    a) Sorts the result set in ascending or descending order.
    b) Limits the number of rows.
    c) Groups the result set.
    d) Filters the records based on a condition.

  17. Which function returns the number of characters in a string?
    a) LENGTH()
    b) COUNT()
    c) CHAR_LENGTH()
    d) SIZE()

  18. Which SQL function is used to concatenate two or more strings in MySQL?
    a) CONCAT()
    b) MERGE()
    c) JOIN()
    d) COMBINE()

  19. Which SQL command is used to remove all the rows from a table without deleting the table itself?
    a) TRUNCATE TABLE
    b) DELETE
    c) DROP TABLE
    d) REMOVE

  20. Which operator is used to find a range of values in a SQL query?
    a) BETWEEN
    b) IN
    c) LIKE
    d) RANGE

    1. Which SQL clause is used to group rows that have the same values into summary rows?
      a) GROUP BY
      b) ORDER BY
      c) HAVING
      d) SELECT

    2. Which of the following SQL statements is used to add a new row to a table?
      a) INSERT INTO
      b) ADD ROW
      c) UPDATE
      d) ADD RECORD

    3. Which SQL keyword is used to specify the column for sorting in descending order?
      a) DESC
      b) ASC
      c) ORDER
      d) SORT

    4. Which SQL statement is used to remove a table from a database?
      a) DROP TABLE
      b) DELETE TABLE
      c) REMOVE TABLE
      d) TRUNCATE TABLE

    5. Which of the following SQL commands is used to change the structure of an existing table?
      a) ALTER TABLE
      b) MODIFY TABLE
      c) CHANGE TABLE
      d) UPDATE TABLE

    6. What is the default sort order used by the ORDER BY clause in SQL?
      a) Ascending (ASC)
      b) Descending (DESC)
      c) Random
      d) None

    7. Which function in SQL is used to return the highest value in a column?
      a) MAX()
      b) MIN()
      c) SUM()
      d) AVG()

    8. Which operator is used in SQL to combine the results of two SELECT statements?
      a) JOIN
      b) UNION
      c) INTERSECT
      d) COMBINE

    9. What does the HAVING clause do in SQL?
      a) Filters records after grouping.
      b) Filters records before grouping.
      c) Specifies the sort order of results.
      d) Limits the number of rows returned.

    10. Which keyword is used in SQL to return the number of rows affected by a query?
      a) ROWCOUNT
      b) COUNT
      c) NUMROWS
      d) TOTAL

    11. Which SQL function is used to find the minimum value in a column?
      a) MIN()
      b) MAX()
      c) AVG()
      d) SUM()

    12. Which SQL clause is used to specify the pattern to search for in a string?
      a) MATCH
      b) LIKE
      c) CONTAINS
      d) EQUALS

    13. Which operator is used to filter the records where a column’s value is between two values in SQL?
      a) IN
      b) BETWEEN
      c) LIKE
      d) MATCH

    14. Which statement is used to combine data from two or more tables in SQL based on a related column?
      a) JOIN
      b) UNION
      c) INTERSECT
      d) MERGE

    15. Which SQL statement is used to retrieve the current system date and time?
      a) NOW()
      b) CURRENT_TIMESTAMP
      c) GETDATE()
      d) SYS_DATE()

    16. Which SQL command is used to remove all rows from a table and reset the table to its empty state without removing the table itself?
      a) TRUNCATE
      b) DELETE
      c) REMOVE
      d) RESET

    17. Which SQL operator is used to test for NULL values?
      a) IS NULL
      b) = NULL
      c) IS EMPTY
      d) NULL TEST

    18. Which SQL function is used to find the total sum of a column’s values?
      a) COUNT()
      b) SUM()
      c) AVG()
      d) MAX()

    19. Which clause is used to define conditions for rows to be included in a SQL query’s result set?
      a) WHERE
      b) HAVING
      c) FILTER
      d) GROUP BY

    20. Which SQL function is used to combine the result of two or more strings?
      a) JOIN()
      b) CONCAT()
      c) COMBINE()
      d) UNION()