Thursday, July 30, 2009

Learn the Modification of the Database

Deletion

- Delete all account records at the Kandy City branch.
delete * from account
where branch_name = ‘Kandy city’

- Delete all accounts at every branch located in Kandy.
delete * from account
where branch_name in (select branch_name
from branch
where branch_city=‘Kandy’)

Insertion

- Add a new tuple to account
insert into account
values (‘200116’, ‘Kandy City’,1200)

or equivalently
insert into account (branch_name, balance, account_number)
values (‘Kandy City’, 1200, ‘200116’)

- Add a new tuple to account with balance set to null
insert into account
values (‘100117’,‘Kandy City’, null)

Updates

- Increase all accounts with balances over Rs.1000 by 6%, all other accounts receive 5%.
- Write two update statements:
update account
set balance = balance *1.06
where balance > 1000
update account
set balance = balance * 1.05
where balance ≤ 1000

No comments:

Post a Comment