Learn MYSQL MCQs
Prepare MYSQL MCQs (Multiple choice Questions) for exam and job interviews.
What does the SQL NOT NULL constraint do?
1) Ensures a column cannot have a NULL value
2) Allows NULL values
3) Sets a default value
4) Creates a unique column
Answer : Option 1
How do you 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 SET name = new_name;
Answer : Option 1
What is the function of the SQL UPPER() function?
1) Converts a string to uppercase
2) Finds the length of a string
3) Counts characters
4) Extracts a substring
Answer : Option 1
Which command is used to execute a stored procedure?
1) CALL procedure_name();
2) EXECUTE procedure_name();
3) RUN procedure_name();
4) INVOKE procedure_name();
Answer : Option 1
What does the SQL COALESCE() function do?
1) Returns the first non-NULL value in a list
2) Counts the number of non-NULL values
3) Finds the minimum value
4) Concatenates strings
Answer : Option 1
How do you drop a column from a table?
1) ALTER TABLE table_name DROP column_name;
2) DELETE COLUMN column_name FROM table_name;
3) REMOVE COLUMN column_name FROM table_name;
4) DROP COLUMN column_name FROM table_name;
Answer : Option 1
Which command is used to set a specific time zone in MySQL?
1) SET time_zone = 'timezone';
2) CHANGE time_zone TO 'timezone';
3) ALTER time_zone TO 'timezone';
4) CONFIGURE time_zone = 'timezone';
Answer : Option 1
How do you create a view in MySQL?
1) CREATE VIEW view_name AS SELECT * FROM table_name;
2) DEFINE VIEW view_name AS SELECT * FROM table_name;
3) NEW VIEW view_name AS SELECT * FROM table_name;
4) ALTER VIEW view_name AS SELECT * FROM table_name;
Answer : Option 1
What does the SQL ROLLBACK command do?
1) Reverts the database to the last commit
2) Commits the current transaction
3) Starts a new transaction
4) Saves the current state of the database
Answer : Option 1
How can you change a data type of a column in MySQL?
1) ALTER TABLE table_name MODIFY column_name new_data_type;
2) CHANGE TABLE table_name CHANGE column_name new_data_type;
3) UPDATE TABLE table_name SET column_name = new_data_type;
4) MODIFY TABLE table_name column_name new_data_type;
Answer : Option 1