首先要创建表,用来存储数据用的:--ATM机实现数据存储过程
/*账户表/交易记录表/转账记录表*/
/*
--账户表:主键,账户,密码,金额,银行类型,创建人,创建时间,修改人,修改时间
*/
select sys_guid() from dual;
create table account_bank(
pk_serial varchar2(32),
account_no varchar2(4),
account_pwd varchar2(6),
account_money number(11,2) default 0.00,
bank_type varchar2(1),
create_by varchar2(50),
create_data date,
update_by varchar2(50),
update_data date
);
comment on table account_bank is '账户表';
comment on column account_bank.pk_serial is '主键';
comment on column account_bank.account_no is '账户';
comment on column account_bank.account_pwd is '密码';
comment on column account_bank.account_money is '金额';
comment on column account_bank.bank_type is '1.工商银行2.建设银行3.农业银行4.中国银行5.邮政储蓄';
comment on column account_bank.create_data is '创建时间';
comment on column account_bank.create_by is '创建人';
comment on column account_bank.update_by is '修改人';
comment on column account_bank.update_data is '修改时间';
create unique index account_bank_no on account_bank(pk_serial);
create unique index account_bank on account_bank(account_no);
--添加主键
alter table account_bank
add constraint pk_account_bank primary key(pk_serial)
using index account_bank_no;
/*
--交易记录表:主键,账号,交易金额,金额,交易类型,交易时间,交易账户,交易状态,创建人,创建时间,修改人,修改时间
*/
create table record_deal(
pk_serial varchar2(32),
account_no varchar2(4),
deal_money number(10,2) default 0.00,
money number(10,2) default 0.00,
deal_type varchar(1),
deal_data date,
deal_account_no varchar2(4),
status varchar(1),
create_by varchar(20),
create_data date,
update_by varchar(20),
update_data date
);
comment on table record_deal is '交易记录表';
comment on column record_deal.pk_serial is '主键';
comment on column record_deal.account_no is '帐号';
comment on column record_deal.deal_money is '交易金额';
comment on column record_deal.money is '金额';
comment on column record_deal.deal_type is '1.存款2.取款3.转入4.转出';
comment on column record_deal.deal_data is '交易时间';
comment on column record_deal.deal_account_no is '交易账户';
comment on column record_deal.status is '交易状态:0.交易成功1.交易失败'
comment on column record_deal.create_by is '创建人';
comment on column record_deal.create_data is '创建时间';
comment on column record_deal.update_by is '修改人';
comment on column record_deal.update_data is '修改时间';
create unique index un_ix_record_deal on record_deal(pk_serial);
alter table record_deal
add constraint pk_record_deal primary key(pk_serial)
using index un_ix_record_deal;
/*
--转账记录表:主键,转出账号,转入帐号,交易金额,交易类型,交易时间,交易状态,创建人,创建时间,修改人,修改时间
*/
create table record_transfer(
pk_serial varchar2(32),
src_account_no varchar2(4),
target_account_no varchar2(4),
record_money number(10,2) default 0.00,
record_type varchar(1),
record_data date,
status varchar(1),
create_by varchar(20),
create_data date,
update_by varchar(20),
update_data date
);
comment on table record_transfer is '转账记录表';
comment on column record_transfer.pk_serial is '主键';
comment on column record_transfer.src_account_no is '转出账号';
comment on column record_transfer.target_account_no is '转入帐号';
comment on column record_transfer.record_money is '交易金额';
comment on column record_transfer.record_type is '交易类型:1.跨行2不跨行';
comment on column record_transfer.record_data is '交易时间';
comment on column record_transfer.status is '交易状态:0.待处理1.完成2.失败3.失效';
comment on column record_transfer.create_by is '创建人';
comment on column record_transfer.create_data is '创建时间';
comment on column record_transfer.update_by is '修改人';
comment on column record_transfer.update_data is '修改时间';
--创建索引
create unique index un_in_record_transfer on record_transfer(pk_serial);
--添加主键
alter table record_transfer
add constraint pk_record_transfer primary key(pk_serial)
using index un_in_record_transfer;