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

MCQ ch7

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)
3 views12 pages

MCQ ch7

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.

**Which of the following SQL features allow users to specify more complex retrievals from a
database?**
- A) Nested queries
- B) Joined tables
- C) Aggregate functions
- D) All of the above
- **Answer: D**

2. **What is the meaning of NULL in SQL?**


- A) Unknown value
- B) Unavailable or withheld value
- C) Not applicable attribute
- D) All of the above
- **Answer: D**

3. **SQL uses a three-valued logic. What are the possible values?**


- A) TRUE, FALSE, NULL
- B) TRUE, FALSE, UNKNOWN
- C) TRUE, NULL, UNKNOWN
- D) FALSE, NULL, UNKNOWN
- **Answer: B**

4. **Which SQL operator checks whether an attribute value is NULL?**


- A) IS NULL
- B) IS NOT NULL
- C) Both A and B
- D) None of the above
- **Answer: C**

5. **What is a nested query in SQL?**


- A) A query that includes subqueries in the SELECT clause
- B) A query that includes subqueries in the WHERE clause
- C) A query that includes subqueries in the FROM clause
- D) All of the above
- **Answer: B**

6. **Which comparison operator can be used with sets or multisets in nested queries?**
- A) IN
- B) ANY
- C) SOME
- D) All of the above
- **Answer: D**

7. **What does the operator `= ANY` (or `= SOME`) return when used in a query?**
- A) TRUE if the value is equal to all values in the set
- B) TRUE if the value is equal to some value in the set
- C) TRUE if the value is not in the set
- D) FALSE if the value is in the set
- **Answer: B**

8. **What is an assertion in SQL?**


- A) A type of constraint on individual attributes
- B) A type of constraint on individual tuples
- C) A query that selects tuples violating a desired condition
- D) A trigger that performs actions when conditions are met
- **Answer: C**

9. **What are the components of a typical SQL trigger?**


- A) Event, Condition, Action
- B) Event, Action, Assertion
- C) Condition, Action, Assertion
- D) Event, Condition, Assertion
- **Answer: A**

10. **Which command is used to create a trigger in SQL?**


- A) CREATE ASSERTION
- B) CREATE TRIGGER
- C) CREATE VIEW
- D) CREATE FUNCTION
- **Answer: B**

11. **In the context of SQL, what is a view?**


- A) A real table stored in the database
- B) A virtual table derived from other tables
- C) A trigger for monitoring changes
- D) A constraint for ensuring data integrity
- **Answer: B**

12. **What is the purpose of the CREATE VIEW command?**


- A) To create a new table
- B) To define a virtual table with a query
- C) To update an existing view
- D) To delete an existing view
- **Answer: B**

13. **How does SQL ensure that a view is always up-to-date?**


- A) By manually refreshing the view
- B) By automatically updating the view
- C) By storing the view as a table
- D) By using triggers
- **Answer: B**
14. **Which command is used to delete a view in SQL?**
- A) DELETE VIEW
- B) REMOVE VIEW
- C) DROP VIEW
- D) ALTER VIEW
- **Answer: C**

15. **What is the main advantage of the query modification approach for view
implementation?**
- A) Efficiency in querying
- B) Simplicity in updating
- C) Avoiding storage of view tables
- D) Reducing query execution time
- **Answer: C**

16. **What is view materialization in SQL?**


- A) Creating a view on-the-fly
- B) Physically storing the view as a table
- C) Dropping a view when no longer needed
- D) Using a view in a nested query
- **Answer: B**

17. **Which strategy for view materialization updates the view immediately after the base
tables change?**
- A) Immediate update strategy
- B) Lazy update strategy
- C) Periodic update strategy
- D) On-demand update strategy
- **Answer: A**
18. **Which statement is true about updating views?**
- A) All views can be updated directly
- B) Views with joins can always be updated
- C) Views without aggregate functions and with a single base table can often be updated
- D) No views can be updated
- **Answer: C**

19. **What does the clause WITH CHECK OPTION ensure in a view definition?**
- A) That tuples being updated stay in the view
- B) That the view is always materialized
- C) That the view is automatically updated
- D) That the view is deleted when not needed
- **Answer: A**

20. **Which command is used to add a column to an existing table in SQL?**


- A) ADD COLUMN
- B) ALTER TABLE
- C) MODIFY TABLE
- D) INSERT COLUMN
- **Answer: B**

21. **What does the CASCADE option do when dropping a schema?**


- A) Drops the schema only if it is empty
- B) Drops the schema and all its elements
- C) Drops the schema if it has no foreign keys
- D) Drops the schema and renames it
- **Answer: B**

22. **What is the purpose of the ALTER TABLE command in SQL?**


- A) To modify an existing table
- B) To delete an existing table
- C) To create a new table
- D) To query a table
- **Answer: A**

23. **How can a default value for a column be dropped in SQL?**


- A) ALTER COLUMN DROP DEFAULT
- B) REMOVE COLUMN DEFAULT
- C) DELETE COLUMN DEFAULT
- D) ALTER TABLE DROP DEFAULT
- **Answer: A**

24. **Which of the following is true about SQL triggers?**


- A) They are used to enforce constraints
- B) They can perform actions in response to certain events
- C) They are only used for data validation
- D) They cannot access other tables
- **Answer: B**

25. **What does the CREATE TRIGGER statement do?**


- A) Creates a new table
- B) Creates a new view
- C) Creates a rule for automatic actions in response to events
- D) Creates a new schema
- **Answer: C**

26. **Which of the following SQL features can be used to hide certain attributes from
unauthorized users?**
- A) Assertions
- B) Triggers
- C) Views
- D) Indexes
- **Answer: C**

27. **What is the DROP command used for in SQL?**


- A) To delete rows from a table
- B) To remove named schema elements
- C) To modify the structure of a table
- D) To insert data into a table
- **Answer: B**

28. **In the context of SQL views, what does the term "inline view" refer to?**
- A) A view that is defined within the FROM clause of a query
- B) A view that is permanently stored in the database
- C) A view that is updated immediately after changes
- D) A view that cannot be updated
- **Answer: A**

29. **What is the purpose of the CREATE ASSERTION command in SQL?**


- A) To create a new table
- B) To specify a query that selects any tuples violating a condition
- C) To create a virtual table
- D) To drop a schema element
- **Answer: B**

30. **Which of the following is an example of a semantic constraint that can be specified as an
assertion in SQL?**
- A) NOT NULL constraint
- B) UNIQUE constraint
- C) A complex condition involving multiple attributes and tables
- D) Primary key constraint
- **Answer: C**
31. **How can complex conditions that go beyond simple attribute and domain checks be
enforced in SQL?**
- A) Using primary keys
- B) Using foreign keys
- C) Using assertions
- D) Using indexes
- **Answer: C

**

32. **What is the purpose of the ALTER SCHEMA command in SQL?**


- A) To change the name of the schema
- B) To add or drop schema elements
- C) To modify table structures within the schema
- D) All of the above
- **Answer: D**

33. **Which clause can be used to filter rows in the results of an SQL query?**
- A) SELECT
- B) WHERE
- C) FROM
- D) GROUP BY
- **Answer: B**

34. **What is the purpose of the GROUP BY clause in SQL?**


- A) To filter rows
- B) To group rows sharing a property for aggregate functions
- C) To sort rows
- D) To join tables
- **Answer: B**
35. **How can an SQL trigger be specified to activate only once for the triggering statement,
rather than once for each row?**
- A) By using FOR EACH ROW
- B) By using FOR EACH STATEMENT
- C) By using FOR EACH TRANSACTION
- D) By using FOR EACH ACTION
- **Answer: B**

36. **Which of the following statements about SQL triggers is false?**


- A) Triggers can be used to enforce referential integrity
- B) Triggers can only be used with SELECT statements
- C) Triggers can perform actions such as INSERT, UPDATE, and DELETE
- D) Triggers can be used to automatically update views
- **Answer: B**

37. **Which SQL feature allows the definition of a virtual table based on a query?**
- A) Trigger
- B) Assertion
- C) View
- D) Index
- **Answer: C**

38. **What does the RENAME command do in SQL?**


- A) Renames a table
- B) Renames a view
- C) Renames a column
- D) All of the above
- **Answer: D**
39. **Which of the following can be used to perform operations in response to changes in the
database?**
- A) Assertions
- B) Triggers
- C) Views
- D) Queries
- **Answer: B**

40. **What is the main benefit of using triggers in SQL?**


- A) To automate repetitive tasks
- B) To enforce complex business rules
- C) To ensure data integrity
- D) All of the above
- **Answer: D**

41. **Which command can be used to modify an existing trigger?**


- A) ALTER TRIGGER
- B) MODIFY TRIGGER
- C) UPDATE TRIGGER
- D) REPLACE TRIGGER
- **Answer: A**

42. **What is the purpose of the DROP TRIGGER command?**


- A) To delete a trigger
- B) To disable a trigger
- C) To modify a trigger
- D) To create a new trigger
- **Answer: A**

43. **What is a stored procedure in SQL?**


- A) A precompiled collection of one or more SQL statements
- B) A trigger that is automatically executed
- C) A virtual table derived from a query
- D) An assertion that enforces constraints
- **Answer: A**

44. **Which clause can be used to specify the columns of a table that should be indexed?**
- A) SELECT
- B) INDEX
- C) CREATE INDEX
- D) ALTER INDEX
- **Answer: C**

45. **What is the purpose of the CASCADE option in the DROP TABLE command?**
- A) To drop the table only if it is empty
- B) To drop the table and all objects that depend on it
- C) To drop the table if it has no foreign keys
- D) To rename the table
- **Answer: B**

46. **Which of the following is not a valid aggregate function in SQL?**


- A) COUNT
- B) SUM
- C) AVERAGE
- D) MAX
- **Answer: C**

47. **What does the HAVING clause do in SQL?**


- A) Filters rows before grouping
- B) Filters groups after grouping
- C) Joins tables
- D) Sorts results
- **Answer: B**

48. **Which SQL clause is used to sort the results of a query?**


- A) SELECT
- B) WHERE
- C) ORDER BY
- D) GROUP BY
- **Answer: C**

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


- A) A key that uniquely identifies a row in a table
- B) A key used to enforce referential integrity
- C) A key that cannot contain NULL values
- D) A key used for indexing
- **Answer: B**

50. **How can you ensure that an attribute in an SQL table must always have a value?**
- A) By defining it as a primary key
- B) By using the NOT NULL constraint
- C) By defining it as a foreign key
- D) By creating an index on the attribute
- **Answer: B**

These questions cover various aspects of SQL queries, triggers, views, and schema
modifications as discussed in the provided text.

You might also like