What is a transaction in a database?
a) A group of SQL statements that must be executed as a single unit
b) A single SQL query to retrieve data
c) A record of changes made to the database
d) A copy of the database
Answer:
a) A group of SQL statements that must be executed as a single unit
Explanation:
A transaction in a database is a group of one or more SQL statements that are executed as a single unit. Transactions follow the ACID properties (Atomicity, Consistency, Isolation, Durability), ensuring that either all statements are executed successfully, or none are executed at all.
Transactions are important for maintaining data integrity, especially in multi-user environments. They ensure that operations like updates, inserts, or deletes do not leave the database in an inconsistent state.
Examples of transactional operations include transferring funds between accounts or updating multiple related records in a database.