create table MyCustomers (
cid number(6,0) primary key,
name varchar2(50),
address varchar2(100)
);
create table MyAccounts (
aid number(10,0) primary key,
openAt date,
balance number(12, 2),
owner number(6,0) references MyCustomers
);
alter table MyCustomers
add email varchar2(100);
insert into MyCustomers (cid, name, address)
values (1, 'Gary Barry', '101 Main Street');
insert into MyCustomers (cid, name, address)
values (2, 'Mary Sanly', '22 Baker Street');
insert into MyAccounts (aid, openAt, balance, owner)
values (1001, to_date('2019-05-15', 'yyyy-mm-dd'), 350, 1);
insert into MyAccounts (aid, openAt, balance, owner)
values (1002, to_date('Jan 06, 2020', 'Mon dd, yyyy'), 15.5, 1);
insert into MyAccounts (aid, openAt, balance, owner)
values (2001, to_date('12/20/2019', 'mm/dd/yyyy'), 30000, 2);
insert into MyAccounts (aid, openAt, balance, owner)
values (2002, to_date('15/01/2020', 'dd/mm/yyyy'), 1507, 2);
insert into MyCustomers (cid, name, address, email)
(select employee_id, first_name || ' ' || last_name,
street_address || ', ' || city || ', ' || state_province,
email
from hr.employees E, hr.departments D, hr.locations L
where E.department_id = D.department_id
and D.location_id = L.location_id);
delete
from MyAccounts
where aid = 2002;
delete
from MyAccounts
where owner = some (select cid
from MyCustomers
where name like '% King');
update MyAccounts
set balance = balance + 50
where balance < 500;
drop table MyAccounts;
drop table MyCustomers;