云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > oracle数据库课程设计报告书

oracle数据库课程设计报告书

  • 62 次阅读
  • 3 次下载
  • 2025/6/17 23:46:45

4、 创建存储过程

--存放过程

/*删除不报错过程*/

CREATE OR REPLACE PROCEDURE ifExistDel(sqls varchar2)

AS BEGIN

execute immediate sqls; exception

when others then dbms_output.put_line(SQLERRM); END

ifExistDel; BEGIN

--如果表存在则删除

ifExistDel('drop table tb_booksinfo cascade constraints '); ifExistDel('drop table tb_book_type cascade constraints '); ifExistDel('drop table tb_deliverinfo cascade constraints'); ifExistDel('drop table tb_order_main cascade constraints'); ifExistDel('drop table tb_order_detail cascade constraints'); ifExistDel('drop table tb_order_state cascade constraints'); ifExistDel('drop table tb_user_main cascade constraints');

ifExistDel('drop table tb_user_type cascade constraints'); ifExistDel('drop table tb_shoppinginfo cascade constraints'); --如果序列存在则删除

ifExistDel('drop sequence booksinfo_seq'); ifExistDel('drop sequence order_main_seq'); ifExistDel('drop sequence deliverinfo_seq'); ifExistDel('drop sequence user_main_seq'); ifExistDel('drop sequence book_type_seq'); ifExistDel('drop sequence order_state_seq'); END;

5、 建表

/*书籍信息表*/

create table tb_booksinfo(

bookID varchar2(20) primary key,

bookNumber int, bookTitle varchar2(250) not null, --bookPrice number(10,2), bookPicture varchar2(250), bookDesc varchar2(4000), --typeID varchar2(20), --author varchar2(20), --bookStat varchar2(20) );

/*书籍类型表*/

create table tb_book_type(

typeID varchar2(20) primary key, typeName varchar2(20) ); /*订单表*/

create table tb_order_main(

orderID varchar2(20) primary key, createDate date, --orderTotal Number(10,2), --endDate date, deliverID varchar2(20), osID varchar2(20) );

/*收货信息表*/

create table tb_deliverinfo(

deliverID varchar2(20) primary key, --deliverName varchar2(40), --deliverPhone varchar2(40), --deliverAddress varchar2(500), --deliverPostcode varchar2(20), --书籍库存 书籍名称 书籍价格 书籍图片地址 书籍描述 书籍类型(外键-1) 书籍作者

书籍状态(下架,上架) 订单建立时间 订单总价格 订单结束时间

收货信息编号(外键-7)订单状态编号(外键-8)收货信息编号 收货人 联系 收货地址 收货邮编

-- -- -- -- -- -- --

userID varchar2(20), --用户编号(外键-9) identityCard varchar2(60) --收货人身份证号

);

/*订单书籍信息表*/

create table tb_order_detail(

orderID varchar2(20), --订单编号(外键-5) bookNumber int, --书籍购买数量

bookID varchar2(20) --书籍编号 (外键-6)

);

/*订单状态表*/

create table tb_order_state( osID varchar2(20) primary key, osName varchar2(20) --订单状态(审核中,已发货,已签收,未签收,取消)

);

/*用户表*/

create table tb_user_main(

userID varchar2(20) primary key, userName varchar2(20) unique, userPassword varchar2(20),

utID varchar2(20), --用户类型编号(外键-4) email varchar2(100) unique); /*用户类型表*/

create table tb_user_type( utID varchar2(20) primary key, utName varchar2(20) not null); /*购物信息表*/

create table tb_shoppinginfo( bookNumber int,

bookID varchar2(20), --商品编号(外键-3) userID varchar2(20) --用户编号(外键-2)

);

6、 建立外键约束

/*书籍--书籍类型-1*/

alter table tb_booksinfo add constraint f_book_type foreign key (typeID) references tb_book_type(typeID); /*购物信息--用户-2*/

alter table tb_shoppinginfo add constraint f_shoppinginfo_user foreign key (userID) references tb_user_main(userID); /*购物信息--书籍-3*/

alter table tb_shoppinginfo add constraint f_shoppinginfo_book foreign key

(bookID) references tb_booksinfo(bookID); /*用户--用户类型-4*/

alter table tb_user_main add constraint f_user_userType foreign key

(utID) references tb_user_type(utID); /*订单书籍--订单-5*/

alter table tb_order_detail add constraint f_detail_order foreign key (orderID) references tb_order_main(orderID); /*订单书籍--书籍-6*/

alter table tb_order_detail add constraint f_detail_booksinfo foreign key (bookID) references tb_booksinfo(bookID); /*订单--收货信息-7*/

alter table tb_order_main add constraint f_order_deliver foreign key (deliverID) references tb_deliverinfo(deliverID); /*订单--订单状态-8*/

alter table tb_order_main add constraint f_order_state foreign key (osID) references tb_order_state(osID); /*收货信息-用户-9*/

alter table tb_deliverinfo add constraint f_deliver_state foreign key (userID) references tb_user_main(userID);

7、 创建序列

/*书籍信息表序列*/

create sequence booksinfo_seq start with 1

increment by 1 maxvalue 200000 minvalue 1 nocycle;

/*订单表序列*/

create sequence order_main_seq

start with 1 increment by 1 maxvalue 200000 minvalue 1 nocycle;

/*订单状态序列*/

create sequence order_state_seq

start with 1 increment by 1 maxvalue 200 minvalue 1 nocycle;

/*收货信息表序列*/

create sequence deliverinfo_seq

start with 1 increment by 1 maxvalue 200000

搜索更多关于: oracle数据库课程设计报告书 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

4、 创建存储过程 --存放过程 /*删除不报错过程*/ CREATE OR REPLACE PROCEDURE ifExistDel(sqls varchar2) AS BEGIN execute immediate sqls; exception when others then dbms_output.put_line(SQLERRM); END ifExistDel; BEGIN --如果表存在则删除 ifExistDel('drop table tb_booksinfo cascade constraints '); ifExistDel('drop table

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com