Learn MYSQL MCQs
Prepare MYSQL MCQs (Multiple choice Questions) for exam and job interviews.
Which SQL command is used to export data from a table?
1) SELECT INTO OUTFILE
2) EXPORT TABLE
3) SAVE TABLE AS
4) COPY TABLE TO
Answer : Option 1
What does the SQL IF statement do?
1) Returns a value based on a condition
2) Checks for NULL values
3) Counts records
4) Filters results
Answer : Option 1
How do you limit the number of rows returned by a SELECT statement?
1) SELECT * FROM table_name LIMIT number;
2) SELECT TOP number FROM table_name;
3) SELECT FIRST number FROM table_name;
4) SELECT number ROWS FROM table_name;
Answer : Option 1
Which SQL function is used to convert a string to a date?
1) STR_TO_DATE()
2) CONVERT_TO_DATE()
3) CAST_TO_DATE()
4) DATE_FROM_STRING()
Answer : Option 1
How do you create a composite unique constraint in MySQL?
1) ALTER TABLE table_name ADD UNIQUE (column1, column2);
2) CREATE UNIQUE (column1, column2) ON table_name;
3) ADD UNIQUE CONSTRAINT (column1, column2) TO table_name;
4) DEFINE UNIQUE (column1, column2) ON table_name;
Answer : Option 1
What is the SQL command to add a comment in the code?
1) -- This is a comment
2) /* This is a comment */
3) # This is a comment
4) COMMENT This is a comment
Answer : Option 1
How do you get the number of records in a result set?
1) SELECT COUNT(*) FROM table_name;
2) SELECT TOTAL(*) FROM table_name;
3) SELECT NUMBER(*) FROM table_name;
4) SELECT SUM(*) FROM table_name;
Answer : Option 1
Which SQL statement is used to change a table structure?
1) ALTER TABLE table_name;
2) CHANGE TABLE table_name;
3) UPDATE TABLE table_name;
4) MODIFY TABLE table_name;
Answer : Option 1
What does the SQL AS keyword do?
1) Renames a column or table
2) Creates an alias
3) Filters results
4) Sorts records
Answer : Option 1