πŸ“Š MySQL
Q. Which command is used to remove a table from a database?
  • (A) DELETE TABLE
  • (B) REMOVE TABLE
  • (C) DROP TABLE
  • (D) DESTROY TABLE
πŸ’¬ Discuss
βœ… Correct Answer: (C) DROP TABLE

Explanation: `DROP TABLE` deletes the table and all of its data permanently.

πŸ“Š MySQL
Q. Which of the following is a valid way to create an index?
  • (A) CREATE KEY idx_name ON table(column);
  • (B) MAKE INDEX idx_name ON table(column);
  • (C) CREATE INDEX idx_name ON table(column);
  • (D) SET INDEX ON table(column);
πŸ’¬ Discuss
βœ… Correct Answer: (C) CREATE INDEX idx_name ON table(column);

Explanation: `CREATE INDEX` is the correct syntax to create an index in MySQL.

πŸ“Š MySQL
Q. What does this query do?
Code:
SELECT name FROM students WHERE name LIKE 'A%';
  • (A) Selects students with names starting with A
  • (B) Selects students with names ending in A
  • (C) Selects students with names containing A
  • (D) Selects all students
πŸ’¬ Discuss
βœ… Correct Answer: (A) Selects students with names starting with A

Explanation: `'A%'` matches strings that start with 'A'.

πŸ“Š MySQL
Q. Which clause is used to limit the number of rows returned?
  • (A) RESTRICT
  • (B) LIMIT
  • (C) ROWNUM
  • (D) TOP
πŸ’¬ Discuss
βœ… Correct Answer: (B) LIMIT

Explanation: `LIMIT` is used to specify the number of records to return.

πŸ“Š MySQL
Q. How do you rename a column in MySQL?
  • (A) RENAME COLUMN old TO new;
  • (B) ALTER TABLE t RENAME old TO new;
  • (C) ALTER TABLE t CHANGE old new datatype;
  • (D) SET COLUMN old AS new;
πŸ’¬ Discuss
βœ… Correct Answer: (C) ALTER TABLE t CHANGE old new datatype;

Explanation: `ALTER TABLE ... CHANGE old_name new_name datatype;` is used to rename a column.

πŸ“Š MySQL
Q. Which keyword is used to define a foreign key in MySQL?
  • (A) EXTERNAL KEY
  • (B) FOREIGN KEY
  • (C) REF KEY
  • (D) LINK KEY
πŸ’¬ Discuss
βœ… Correct Answer: (B) FOREIGN KEY

Explanation: `FOREIGN KEY` enforces referential integrity between two related tables.

πŸ“Š MySQL
Q. Which type of JOIN returns only matching rows from both tables?
  • (A) LEFT JOIN
  • (B) RIGHT JOIN
  • (C) FULL JOIN
  • (D) INNER JOIN
πŸ’¬ Discuss
βœ… Correct Answer: (D) INNER JOIN

Explanation: `INNER JOIN` returns rows when there is at least one match in both tables.

πŸ“Š MySQL
Q. What will this query do?
Code:
SELECT AVG(score) FROM results;
  • (A) Finds the maximum score
  • (B) Finds the minimum score
  • (C) Finds the average score
  • (D) Finds the sum of scores
πŸ’¬ Discuss
βœ… Correct Answer: (C) Finds the average score

Explanation: `AVG()` returns the average of a numeric column.

πŸ“Š MySQL
Q. Which constraint ensures that all values in a column are different?
  • (A) NOT NULL
  • (B) DEFAULT
  • (C) UNIQUE
  • (D) INDEX
πŸ’¬ Discuss
βœ… Correct Answer: (C) UNIQUE

Explanation: The `UNIQUE` constraint ensures all values in a column are distinct.

πŸ“Š MySQL
Q. How can you select the top 5 rows in a table?
  • (A) SELECT * FROM table LIMIT 5;
  • (B) SELECT TOP 5 FROM table;
  • (C) SELECT LIMIT 5 FROM table;
  • (D) SELECT FIRST 5 FROM table;
πŸ’¬ Discuss
βœ… Correct Answer: (A) SELECT * FROM table LIMIT 5;

Explanation: `LIMIT 5` returns the first 5 rows from the result set.