Learn MYSQL MCQs
Prepare MYSQL MCQs (Multiple choice Questions) for exam and job interviews.
Which command is used to restore a MySQL database from a backup?
1) mysql -u username -p database_name < backup.sql
2) restore -u username -p database_name < backup.sql
3) import -u username -p database_name < backup.sql
4) load -u username -p database_name < backup.sql
Answer : Option 1
What is the function of the LIKE clause?
1) To search for a specified pattern in a column
2) To sort records
3) To filter records
4) To group records
Answer : Option 1
Which command is used to rename a table in MySQL?
1) RENAME TABLE old_name TO new_name;
2) ALTER TABLE old_name RENAME TO new_name;
3) CHANGE TABLE old_name TO new_name;
4) UPDATE TABLE old_name TO new_name;
Answer : Option 1
What does the NOW() function return?
1) The current date and time
2) The current user
3) The current database
4) The current table
Answer : Option 1
Which command is used to view the structure of a table?
1) DESCRIBE table_name;
2) SHOW table_name;
3) VIEW table_name;
4) STRUCTURE table_name;
Answer : Option 1
What is the function of the ALTER TABLE command?
1) To modify an existing table
2) To create a new table
3) To delete a table
4) To rename a table
Answer : Option 1
Which function is used to find the length of a string?
1) LENGTH(string)
2) SIZE(string)
3) COUNT(string)
4) CHAR_LENGTH(string)
Answer : Option 1
What does the CHAR_LENGTH function return?
1) The number of characters in a string
2) The number of bytes in a string
3) The size of a string in memory
4) The number of words in a string
Answer : Option 1
Which command is used to delete all records from a table without removing the table structure?
1) TRUNCATE TABLE table_name;
2) DELETE FROM table_name;
3) DROP TABLE table_name;
4) REMOVE FROM table_name;
Answer : Option 1
What is the function of the AUTO_INCREMENT attribute?
1) Automatically generates a unique number for each record
2) Increases the value of a column by a fixed amount
3) Automatically increments a date column
4) Automatically adds a row to a table
Answer : Option 1