0% found this document useful (0 votes)
4 views12 pages

MCQ CH - 6

Uploaded by

Mam Hi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views12 pages

MCQ CH - 6

Uploaded by

Mam Hi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1. **What does SQL stand for?

**
- a) Structured Query Language
- b) Sequential Query Language
- c) Standard Query Language
- d) Simple Query Language
- **Answer:** a) Structured Query Language

2. **Which SQL command is used to create a new table?**


- a) INSERT
- b) CREATE
- c) ADD
- d) MAKE
- **Answer:** b) CREATE

3. **Which of the following is NOT a basic constraint type in SQL?**


- a) Key constraint
- b) Entity Integrity constraint
- c) Referential integrity constraint
- d) Domain constraint
- **Answer:** d) Domain constraint

4. **What is the purpose of the PRIMARY KEY constraint?**


- a) To ensure unique values in a column
- b) To enforce referential integrity
- c) To allow null values
- d) To create a foreign key
- **Answer:** a) To ensure unique values in a column

5. **Which SQL clause is used to filter records?**


- a) SELECT
- b) FROM
- c) WHERE
- d) GROUP BY
- **Answer:** c) WHERE

6. **Which command is used to remove a table from a database?**


- a) DELETE TABLE
- b) DROP TABLE
- c) REMOVE TABLE
- d) DESTROY TABLE
- **Answer:** b) DROP TABLE

7. **Which SQL statement is used to update data in a database?**


- a) MODIFY
- b) UPDATE
- c) CHANGE
- d) SET
- **Answer:** b) UPDATE

8. **Which of the following SQL statements is used to retrieve data from a database?**
- a) GET
- b) SELECT
- c) EXTRACT
- d) RETRIEVE
- **Answer:** b) SELECT

9. **Which keyword is used to sort the result-set in SQL?**


- a) SORT BY
- b) ORDER BY
- c) ARRANGE BY
- d) ORGANIZE BY
- **Answer:** b) ORDER BY

10. **What does the SQL WHERE clause do?**


- a) Filters records
- b) Groups records
- c) Orders records
- d) Joins tables
- **Answer:** a) Filters records

11. **Which SQL statement is used to add new data into a database?**
- a) ADD
- b) APPEND
- c) INSERT
- d) UPDATE
- **Answer:** c) INSERT

12. **Which keyword is used to eliminate duplicate rows from the result set in SQL?**
- a) NO DUPLICATE
- b) DISTINCT
- c) UNIQUE
- d) DIFFERENT
- **Answer:** b) DISTINCT

13. **What type of join returns all records when there is a match in either left or right
table?**
- a) INNER JOIN
- b) OUTER JOIN
- c) LEFT JOIN
- d) RIGHT JOIN
- **Answer:** b) OUTER JOIN
14. **Which of the following is a valid SQL comment?**
- a) //
- b) --
- c) ##
- d) **
- **Answer:** b) --

15. **Which SQL clause is used to group rows that have the same values in specified
columns?**
- a) GROUP BY
- b) ORDER BY
- c) WHERE
- d) HAVING
- **Answer:** a) GROUP BY

16. **Which SQL clause is used to filter groups after the GROUP BY clause?**
- a) WHERE
- b) HAVING
- c) FILTER
- d) SELECT
- **Answer:** b) HAVING

17. **What does the COUNT function do in SQL?**


- a) Calculates the sum of a column
- b) Returns the number of rows
- c) Calculates the average value
- d) Returns the largest value
- **Answer:** b) Returns the number of rows

18. **What is the purpose of the SQL SELECT statement?**


- a) To delete data from a table
- b) To update existing data
- c) To insert new data
- d) To retrieve data from a database
- **Answer:** d) To retrieve data from a database

19. **Which SQL keyword is used to retrieve all records from a table?**
- a) GET
- b) RETRIEVE
- c) SELECT
- d) FETCH
- **Answer:** c) SELECT

20. **What does the SQL INNER JOIN clause do?**


- a) Joins tables with unmatched rows
- b) Joins tables with matched rows
- c) Joins tables without any condition
- d) Joins tables based on the primary key
- **Answer:** b) Joins tables with matched rows

21. **Which SQL statement is used to remove existing records from a table?**
- a) REMOVE
- b) DELETE
- c) DROP
- d) CLEAR
- **Answer:** b) DELETE

22. **Which SQL function is used to find the minimum value in a column?**
- a) LEAST
- b) MIN
- c) SMALLEST
- d) LOWEST
- **Answer:** b) MIN

23. **What is the result of a SQL SELECT statement with a missing WHERE clause?**
- a) All rows are returned
- b) No rows are returned
- c) Only unique rows are returned
- d) An error is returned
- **Answer:** a) All rows are returned

24. **Which SQL keyword is used to retrieve only unique values from a column?**
- a) UNIQUE
- b) DIFFERENT
- c) DISTINCT
- d) SEPARATE
- **Answer:** c) DISTINCT

25. **Which clause is used to specify the condition to join two tables in SQL?**
- a) WHERE
- b) JOIN
- c) ON
- d) WITH
- **Answer:** c) ON

26. **Which command is used to change the structure of a table after it has been created?**
- a) MODIFY TABLE
- b) CHANGE TABLE
- c) ALTER TABLE
- d) UPDATE TABLE
- **Answer:** c) ALTER TABLE

27. **Which SQL function is used to calculate the average value of a column?**
- a) TOTAL
- b) AVERAGE
- c) MEAN
- d) AVG
- **Answer:** d) AVG

28. **Which of the following is a valid SQL aggregate function?**


- a) SUM
- b) COMBINE
- c) JOIN
- d) SORT
- **Answer:** a) SUM

29. **What does the SQL SELECT * statement do?**


- a) Selects all columns from a table
- b) Selects the first column from a table
- c) Selects the primary key from a table
- d) Selects the unique rows from a table
- **Answer:** a) Selects all columns from a table

30. **Which SQL command is used to modify the values of existing records in a table?**
- a) ALTER
- b) CHANGE
- c) MODIFY
- d) UPDATE
- **Answer:** d) UPDATE
31. **Which of the following is a set function in SQL?**
- a) COUNT
- b) JOIN
- c) SELECT
- d) WHERE
- **Answer:** a) COUNT

32. **What does the SQL keyword DISTINCT do?**


- a) Returns all records, including duplicates
- b) Returns only unique records
- c) Sorts the result set
- d) Groups the result set
- **Answer:** b) Returns only unique records

33. **Which SQL clause is used to specify the columns to be displayed in the result set?**
- a) FROM
- b) SELECT
- c) WHERE
- d) DISPLAY
- **Answer:** b) SELECT

34. **Which SQL statement is used to create a view?**


- a) MAKE VIEW
- b) ADD VIEW
- c) CREATE VIEW
- d) DEFINE VIEW
- **Answer:** c) CREATE VIEW

35. **What is a foreign key in SQL?**


- a) A key that uniquely identifies each record in a table
- b) A key used to link two tables together
- c) A key that cannot be null
- d) A key that automatically increments
- **Answer:** b) A key used to link two tables together

36. **Which of the following SQL keywords is used to retrieve data from a database?**
- a) RETRIEVE
- b) FETCH
- c)

SELECT
- d) GET
- **Answer:** c) SELECT

37. **What does the SQL LIKE operator do?**


- a) Compares two values for equality
- b) Matches a pattern within a column
- c) Sorts the result set
- d) Filters the result set by range
- **Answer:** b) Matches a pattern within a column

38. **Which SQL function is used to count the number of rows in a table?**
- a) NUMBER
- b) TOTAL
- c) COUNT
- d) SUM
- **Answer:** c) COUNT

39. **Which SQL keyword is used to sort the result set in ascending order?**
- a) ASC
- b) SORT
- c) ORDER
- d) UP
- **Answer:** a) ASC

40. **Which SQL clause is used to specify the table to query data from?**
- a) SELECT
- b) FROM
- c) WHERE
- d) JOIN
- **Answer:** b) FROM

41. **What is the result of the SQL expression: SELECT COUNT(*) FROM table_name?**
- a) The sum of values in a column
- b) The total number of rows in the table
- c) The number of unique values in a column
- d) The maximum value in a column
- **Answer:** b) The total number of rows in the table

42. **Which of the following statements is used to add a new row to a table in SQL?**
- a) ADD ROW
- b) INSERT INTO
- c) ADD INTO
- d) CREATE ROW
- **Answer:** b) INSERT INTO

43. **Which of the following is a valid SQL alias for a column?**


- a) column_name AS alias_name
- b) alias_name AS column_name
- c) alias_name := column_name
- d) column_name := alias_name
- **Answer:** a) column_name AS alias_name

44. **Which SQL statement is used to create an index on a table?**


- a) CREATE INDEX
- b) ADD INDEX
- c) MAKE INDEX
- d) INSERT INDEX
- **Answer:** a) CREATE INDEX

45. **What does the SQL statement ALTER TABLE table_name ADD column_name
data_type do?**
- a) Deletes a column from a table
- b) Changes the data type of a column
- c) Adds a new column to a table
- d) Renames a column in a table
- **Answer:** c) Adds a new column to a table

46. **Which SQL function returns the largest value in a column?**


- a) MAX
- b) GREATEST
- c) LARGE
- d) BIG
- **Answer:** a) MAX

47. **Which SQL command is used to remove all rows from a table without removing the table
structure?**
- a) DROP
- b) DELETE
- c) REMOVE
- d) TRUNCATE
- **Answer:** d) TRUNCATE

48. **What is the purpose of the SQL HAVING clause?**


- a) To specify conditions on individual rows
- b) To specify conditions on groups of rows
- c) To specify the columns to be displayed
- d) To sort the result set
- **Answer:** b) To specify conditions on groups of rows

49. **Which SQL statement is used to change the name of a table?**


- a) ALTER TABLE RENAME TO new_table_name
- b) RENAME TABLE TO new_table_name
- c) MODIFY TABLE new_table_name
- d) UPDATE TABLE new_table_name
- **Answer:** a) ALTER TABLE RENAME TO new_table_name

50. **What does the SQL UNION operator do?**


- a) Combines the result of two queries and returns duplicate rows
- b) Combines the result of two queries and returns all unique rows
- c) Joins two tables
- d) Updates two tables
- **Answer:** b) Combines the result of two queries and returns all unique rows

You might also like