Page 485 - Computer_Science_F5
P. 485
Computer Science (b) ROLLBACK
If you have used the UPDATE command to make some changes to the database
and realise that those changes were not required, you can use the ROLLBACK
command to roll back those changes if they were not committed using the COMMIT
command.
FOR ONLINE READING ONLY
Example:
Delete from student_registration
Where address = 250 Dodoma;
Rollback;
(c) SAVEPOINT
Is also a command used within transactions to establish a point to which you can
later roll back without affecting the entire transaction. It is used to roll back the
transaction to a certain point without rolling back the entire transaction. The syntax
for the savepoint commands is SAVEPOINT savepoint_name;
Example:
UPDATE class SET name = ‘Mwamtumu’ WHERE id = ‘5’;
SAVEPOINT A;
Instructions:
Activity 8.9:
Step 1: Identify a problem
Designing a database table using Think of a practical scenario or problem
SQL that requires storing information in a
database table with 5 to 10 columns.
Aim: For example, it could be a table to store
To practice designing and customer information, product details,
implementing a database table using student records, and so on.
SQL, focusing on schema creation and
data population with 5 to 10 columns. Step 2: Design a database
Design the schema of your database
Materials: table. Define 5 to 10 columns and their
1. Computer with database respective data types based on the
management system (DBMS) information you need to store. Consider
software (such as MySQL, primary keys, foreign keys, and any
PostgreSQL) necessary constraints.
2. SQL database environment set Step 3: Create SQL table
up on your computer or a remote Using your preferred DBMS software,
server write SQL commands to create the
476
for Advanced Secondary Schools
Computer Science Form 5.indd 476 23/07/2024 12:35

