2024年4月2日发(作者:)

use stuDB

go

--创建帐户信息表 bank 和交易信息表 transInfo

if exists(select * from sysobjects where name='bank')

drop table bank

if exists(select * from sysobjects where name='transInfo')

drop table transInfo

go

create table bank --帐户信息表

(

customerName char(8) not null, --顾客姓名

cardID char(10) not null, --卡号

currentMoney money not null --当前余额

)

go

create table transInfo --交易信息表

(

cardID char(10) not null, --卡号

transType char(4) not null, --交易类型(存入/支取)

transMoney money not null, --交易金额

transDate datetime not null --交易日期

)

go

/*----添加约束:帐户余额不能少于1元,交易日期默认为当天日期----*/

alter table bank add constraint CK_currentMoney check(currentMoney>=1)

alter table transInfo add constraint DF_transDate default (getDate()) for

transDate