一个简单的oracle数据库实现ATM存储过程
仅供学习者来参观,大神请移步,本人只是菜鸟级别的。大家把_data的data改成date
'create_data'改为'create_date'像这样。
规范问题 一不小心写错了请谅解。
首先要创建表,用来存储数据用的:--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;
先写到这里创建表下午在把后面的存储过程写上,因为这里只是简单创建表就不添加截图了 自己可以直接在orcale中运行就可以
学习一下 顺便看看复习复习谢谢分享 ATM高大上的样子 http://www.heniyi.com/img/dot.jpg新人贴要支持一下 a2523188267 发表于 2016-12-2 10:55
ATM高大上的样子
没有啦 只是简单的demo而已
页:
[1]