Disclaimer:
Educational Use Only:
The website links provided are to be used strictly for educational and knowledge-gaining purposes only.
No Misuse:
Do not misuse the links or the information contained therein for any commercial, illegal, or unethical activities.
Respect for Websites and Businesses:
Respect the intellectual property and business interests of the websites and their owners. Do not attempt to alter, copy, or redistribute content without proper authorization.
Acknowledge Value of Knowledge:
Recognize and value the knowledge and resources shared by these websites. Use the information responsibly and ethically.
No Endorsement:
The provision of these links does not imply endorsement of the linked sites, their content, or their products and services. Users are responsible for evaluating the suitability and accuracy of the information.
User Responsibility:
By accessing these links, you agree to use the information at your own risk and to comply with all applicable laws and website terms of use.
Overall MCQs for Reference
- What SQL clause is used to filter rows based on a condition?
a) FROM
b) WHERE
c) SELECT
d) ORDER BY
Answer: b) WHEREgyansetu - Which SQL keyword helps remove duplicate rows in query results?
a) UNIQUE
b) DISTINCT
c) DUPLICATE
d) DIFFERENT
Answer: b) DISTINCTgyansetu - How do you alias a column in SQL?
a) RENAME
b) AS
c) ALIAS
d) NAME
Answer: b) ASgyansetu - What does the COUNT(*) function do?
a) Counts NULL values
b) Counts all rows including duplicates
c) Counts non-null distinct values
d) Counts only unique rows
Answer: b) Counts all rows including duplicatesgyansetu - Which function returns the length of a string in SQL?
a) LENGTH()
b) SIZE()
c) COUNT()
d) LENGTHOF()
Answer: a) LENGTH()gyansetu - What will the query SELECT LOWER(‘DATA’) return?
a) DATA
b) data
c) Data
d) dATA
Answer: b) datagyansetu - How do you sort query results in ascending order?
a) ORDER BY column DESC
b) ORDER BY column ASC
c) SORT BY column ASC
d) SORT BY column DESC
Answer: b) ORDER BY column ASCgyansetu - Which SQL clause groups rows sharing a common attribute?
a) WHERE
b) GROUP BY
c) ORDER BY
d) HAVING
Answer: b) GROUP BYgyansetu - What is the purpose of the HAVING clause?
a) Filters rows before GROUP BY
b) Filters groups after GROUP BY
c) Joins tables
d) Sorts grouped rows
Answer: b) Filters groups after GROUP BYgyansetu - How do you join two tables on a common key?
a) NUMBER JOIN
b) JOIN ON
c) INNER JOIN
d) CROSS JOIN
Answer: c) INNER JOINsanfoundry - Which join returns all records from left table and matched records from right?
a) INNER JOIN
b) LEFT JOIN
c) RIGHT JOIN
d) FULL JOIN
Answer: b) LEFT JOINsanfoundry - Which clause allows filtering joined data?
a) WHERE
b) ON
c) HAVING
d) GROUP BY
Answer: b) ONsanfoundry - What does the SQL function NOW() return?
a) Current date and time
b) NULL
c) Unix timestamp
d) Current year
Answer: a) Current date and timegyansetu - What is a subquery?
a) Query inside another query
b) Query modifying tables
c) Query creating tables
d) Query updating records
Answer: a) Query inside another querygyansetu - How to select top 5 rows in SQL?
a) SELECT TOP 5
b) SELECT FIRST 5
c) SELECT LIMIT 5
d) SELECT HEAD 5
Answer: a) SELECT TOP 5 or c) SELECT LIMIT 5 (depends on SQL dialect)gyansetu - Which SQL statement deletes all rows but keeps table structure?
a) DELETE
b) DROP
c) TRUNCATE
d) REMOVE
Answer: c) TRUNCATEsanfoundry - How do you add a new column to an existing table?
a) INSERT COLUMN
b) ADD COLUMN
c) ALTER TABLE ADD COLUMN
d) MODIFY TABLE
Answer: c) ALTER TABLE ADD COLUMNsanfoundry - Which SQL keyword is used for pattern matching?
a) LIKE
b) MATCH
c) FIND
d) SEARCH
Answer: a) LIKEgyansetu - What wildcard is used in LIKE for any sequence of characters?
a) _
b) %
c) *
d) ?
Answer: b) %gyansetu - Which function returns the date portion of a datetime value?
a) GETDATE()
b) DATE()
c) NOW()
d) CURDATE()
Answer: d) CURDATE()gyansetu - How can you change all values in a column to uppercase?
a) UPPER()
b) CAPITALIZE()
c) TOUPPER()
d) UCASE()
Answer: a) UPPER()gyansetu - What does the SQL EXISTS operator do?
a) Checks existence of rows in a subquery
b) Checks if a column exists
c) Returns TRUE if table exists
d) Filters NULL values
Answer: a) Checks existence of rows in a subquerygyansetu - Which command shows the table structure?
a) DESCRIBE
b) SHOW TABLE
c) DETAILS
d) STRUCTURE
Answer: a) DESCRIBEgyansetu - What does the COALESCE function do?
a) Returns first non-null value from inputs
b) Counts null values
c) Concatenates strings
d) Checks for nulls
Answer: a) Returns first non-null value from inputsgyansetu - How to rename a table in SQL?
a) ALTER TABLE oldname RENAME TO newname
b) RENAME TABLE oldname TO newname
c) MODIFY TABLE oldname TO newname
d) UPDATE TABLE NAME
Answer: a) ALTER TABLE oldname RENAME TO newnamesanfoundry - What will the query SELECT IFNULL(NULL, ‘Data’) return?
a) NULL
b) Data
c) Error
d) 0
Answer: b) Datagyansetu - Which SQL function returns the day name for a date?
a) DAY()
b) DAYNAME()
c) TO_CHAR()
d) DATEPART()
Answer: b) DAYNAME()gyansetu - What does the SQL function SUBSTRING() do?
a) Extracts part of a string
b) Converts string to uppercase
c) Removes spaces
d) Replaces characters
Answer: a) Extracts part of a stringgyansetu - How do you combine results from two SELECT queries?
a) UNION
b) JOIN
c) MERGE
d) COMBINE
Answer: a) UNIONsanfoundry - Which SQL command is used to insert data into a table?
a) INSERT INTO
b) ADD DATA
c) CREATE DATA
d) UPDATE
Answer: a) INSERT INTOsanfoundry - What does the SQL function ROUND() do?
a) Rounds a number to nearest integer
b) Converts number to string
c) Finds average of numbers
d) Returns ceiling value
Answer: a) Rounds a number to nearest integergyansetu - What is the use of SQL transactions?
a) Group multiple statements into a single unit
b) Store data persistently
c) Encrypt data
d) Backup database
Answer: a) Group multiple statements into a single unitsanfoundry - What keyword rolls back a transaction?
a) ROLLBACK
b) COMMIT
c) SAVEPOINT
d) CANCEL
Answer: a) ROLLBACKsanfoundry - How do you find distinct values in a column?
a) UNIQUE
b) DISTINCT
c) DIFFERENT
d) SPECIAL
Answer: b) DISTINCTgyansetu - Which SQL statement changes existing records?
a) UPDATE
b) MODIFY
c) CHANGE
d) ALTER
Answer: a) UPDATEsanfoundry - What function converts a string to a number in SQL?
a) TO_NUMBER()
b) CAST()
c) CONVERT()
d) All of above
Answer: d) All of abovegyansetu - How to create an index on a table column?
a) CREATE INDEX
b) ADD INDEX
c) MAKE INDEX
d) NEW INDEX
Answer: a) CREATE INDEXsanfoundry - What is a PRIMARY KEY?
a) Uniquely identifies a row
b) Foreign key reference
c) Index on a table
d) Data type constraint
Answer: a) Uniquely identifies a rowsanfoundry - What does the SQL LIKE operator do?
a) Matches specific patterns
b) Compares numbers
c) Joins tables
d) Returns data type
Answer: a) Matches specific patternsgyansetu - What keyword selects all columns in a table?
a) ALL
b) *
c) EVERY
d) ALL COLUMNS
Answer: b) *gyansetu - Which SQL statement is used to remove a table?
a) DELETE TABLE
b) REMOVE TABLE
c) DROP TABLE
d) ERASE TABLE
Answer: c) DROP TABLEsanfoundry - What function returns the current year?
a) YEAR()
b) CURYEAR()
c) YEAROF()
d) NOW()
Answer: a) YEAR()gyansetu - What does the SQL function CONCAT() do?
a) Adds numbers
b) Joins strings
c) Removes spaces
d) Finds length of string
Answer: b) Joins stringsgyansetu - Which clause filters results after aggregation?
a) WHERE
b) HAVING
c) GROUP BY
d) ORDER BY
Answer: b) HAVINGgyansetu - How do you limit the number of rows returned?
a) LIMIT
b) TOP
c) FETCH
d) ALL
Answer: a) LIMITgyansetu - What does the SQL IN operator do?
a) Checks if value matches a list
b) Inserts values
c) Updates values
d) Deletes values
Answer: a) Checks if value matches a listgyansetu - How do you change a column’s datatype?
a) ALTER TABLE MODIFY COLUMN
b) UPDATE COLUMN TYPE
c) CHANGE TABLE COLUMN
d) MODIFY TABLE COLUMN
Answer: a) ALTER TABLE MODIFY COLUMNsanfoundry - What does the INNER JOIN keyword do?
a) Returns rows with matching values in both tables
b) Returns all rows from left table
c) Returns all rows from right table
d) Returns unmatched rows
Answer: a) Returns rows with matching values in both tablessanfoundry - Which keyword returns unique rows combining results of two SELECTs?
a) INTERSECT
b) UNION
c) JOIN
d) MINUS
Answer: b) UNIONsanfoundry - What does the SQL function NOW() return?
a) Current timestamp
b) NULL
c) Date only
d) Time only
Answer: a) Current timestampgyansetu
- https://www.gyansetu.in/blog/sql-query-mcq-quiz-with-answers/
- https://www.sanfoundry.com/1000-sql-questions-answers/
- https://www.igmguru.com/blog/sql-mcqs
- https://www.interviewbit.com/sql-mcq/
- https://help.hackerearth.com/hc/en-us/articles/900004092206-creating-a-custom-sql-question
- https://www.studocu.com/in/document/anna-university/machine-learning/mcq-questions-combined/85488180
- https://interviewkickstart.com/blogs/articles/sql-mcqs-answers
- https://www.scribd.com/document/698854678/SQL-MCQ-Multiple-Choice-Questions-Javatpoint