今天做了一个SSH的整合案例,但是我发现我们班的很多同学多ORACLE的操作不是很熟悉,然后我就自己去研究了一把。写一下小心得。。
1.第一步:创建表空间
create tablespace superhang
logging
datafile 'd:/superhang.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
create tablespace [表空间名字]
logging[日志记录的缺省模式]
datafile [数据库文件的存放路径]
szie [数据库文件的大小]
autoextended [on]--指定是否文件大小自动增长
next 32m maxsize 2048m --指定增长的范围
extent management local;--本地管理
2.第二步:创建临时表空间
create temporary tablespace bocodbtempdbs
tempfile 'd:/bocodbtempdbs01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
3.第三步:创建用户
create user xuhang identified by svse
default tablespace superhang
temporary tablespace bocodbtempdbs;
create user [用户名] identified by [登录密码]
default tablespace [指定默认表空间]
temporary tablespace [指定临时表空间];
4.第四步:为用户授权
grant connect,resource to xuhang;
grant connect,resource to xuhang; --为用户授权
5.我再我附上一段,查询所有表空间的代码
select dbf.tablespace_name,
dbf.totalspace "总量(M)",
dbf.totalblocks as 总块数,
dfs.freespace "剩余总量(M)",
dfs.freeblocks "剩余块数",
(dfs.freespace / dbf.totalspace) * 100 "空闲比例"
from (select t.tablespace_name,
sum(t.bytes) / 1024 / 1024 totalspace,
sum(t.blocks) totalblocks
from dba_data_files t
group by t.tablespace_name) dbf,
(select tt.tablespace_name,
sum(tt.bytes) / 1024 / 1024 freespace,
sum(tt.blocks) freeblocks
from dba_free_space tt
group by tt.tablespace_name) dfs
where trim(dbf.tablespace_name) = trim(dfs.tablespace_name)
6.创建表
create table fproduct(
pId number primary key not null,
pName varchar2(255) not null,
pPrice float default null,
pDate date default null,
constraint uniquePname unique(pName)
);
7.创建序列
create sequence fproduct_seq
start with 1
increment by 1
maxvalue 999999;
8.插入数据
insert into fproduct values(fproduct_seq.nextval,'衬衫',45.0,to_date('2018-04-25','yyyy-mm-dd'));
insert into fproduct values(fproduct_seq.nextval,'裤子',60.5,to_date('2018-04-25','yyyy-mm-dd'));
insert into fproduct values(fproduct_seq.nextval,'帽子',10.2,to_date('2018-04-25','yyyy-mm-dd'));
insert into fproduct values(fproduct_seq.nextval,'鞋子',70.0,to_date('2018-04-25','yyyy-mm-dd'));
insert into fproduct values(fproduct_seq.nextval,'袜子',8.0,to_date('2018-04-25','yyyy-mm-dd'));
--查询结构如下
select * from fproduct;