文档详情

创建图书系统oracle数据库示例.doc

发布:2017-10-27约9.67千字共6页下载文档
文本预览下载声明
--图书系统示例 --相关文件存储在默认目录D:\oracle\product\10.1.0\oradata\orcl --以下代码自动完成表空间和表的创建以及授权*/ --以超级管理员身份连接数据库*/ conn sys/admin as sysdba; --永久表空间:bookspace create tablespace bookspace datafile D:\oracle\product\10.1.0\oradata\orcl\bookspace.dbf size 50M autoextend on next 5M maxsize 100M; --临时表空间:booktemp create temporary tablespace booktemp tempfile D:\oracle\product\10.1.0\oradata\orcl\booktemp.dbf size 10M autoextend on next 2M maxsize 20M; --撤销表空间:bookundo create undo tablespace bokundo datafile D:\oracle\product\10.1.0\oradata\orcl\bookundo.dbf size 50M autoextend on next 5M maxsize 100M --创建所需要用户:bookstore和bookuser,并进行授权。*/ --1. 创建bookstore用户:身份是管理员DBA,为其指定永久表空间和临时表空间。 create user bookstore identified by admin default tablespace bookspace temporary tablespace booktemp quota 20M on bookspace; --2. 创建bookuser用户:普通用户 create user bookuser identified by admin default tablespace bookspace temporary tablespace booktemp quota 20M on bookspace; --3. 为用户授予角色: grant DBA to bookstore; --4.以新用户登录进行下列操作 conn bookstore/admin --1. 类别表 create table type( typeid number(10) primary key, typename varchar2(20) unique not null ) tablespace bookspace; --2. 管理员等级表 create table grade( gradeid number(10) primary key, gradename varchar2(20) unique not null ) tablespace bookspace; --3. 图书信息表 create table book( bookid number(10) primary key, booknumber char(8) unique not null, bookname varchar2(30) not null, bookpress varchar2(40) not null, bookprice number(8,2) not null, typeid number(10) default 1 not null, booktime
显示全部
相似文档