掌握U盘镜像制作的方法
2014-12-10 16:29
218 查看
今天,学习了Oralce分区表的相关问题,对其进行了一些研究。
首先,末尾来看一下在Oracle数据库中采用分区表的必要性。Oracle在空间数据方面主要采用分区表的形式来平衡大表的I/O,同时避免建议超大索引占用空间,有利于数据库的读写性能。
为了能够体现分区表在执行SQL查询时的重要性,我们可以采用一张存储2000行数据的表作为案例进行试验。在这里,以mzl表为例说明:
select * from mzl;
1 13000000004 13000000004 20090305000000 0 0 20090304000000
2 13000000008 13000000008 20090305000000 0 0 20090304000000
3 13000000012 13000000012 20090305000000 0 0 20090304000000
4 13000000015 13000000015 20090305000000 0 0 20090304000000
5 13000000019 13000000019 20090305000000 0 0 20090304000000
6 13000000023 13000000023 20090305000000 0 0 20090304000000
7 13000000027 13000000027 20090305000000 0 0 20090304000000
8 13000000031 13000000031 20090305000000 0 0 20090304000000
9 13000000034 13000000034 20090305000000 0 0 20090304000000
......
这是一张普通类型的表,我们可以把它转化为我们所需要的分区表。与此同时,我们需要做好原表的备份。
1.建立表空间
为了提高数据库的读写性能,我们可以把不同分区存放在不同的表空间里,首先需要预先建立好相应的表空间,否则在创建分区表时,可能会出问题。
create tablespace one datafile 'd:\one.dbf' size 5M;
create tablespace two datafile 'd:\two.dbf' size 5M;
create tablespace three datafile 'f:\three.dbf' size 5M;
create tablespace four datafile 'f:\four.dbf' size 5M;
create tablespace five datafile 'e:\five.dbf' size 5M;
2.建立分区表
create table mzl_p
(
id char(11) not null,
sid char(11) not null,
time varchar(20),
status int,
status2 int,
log varchar(20)
)
partition by range(sid) #按照sid范围进行分区
(
partition s1 values less than (13000004000) tablespace one,
partition s2 values less than (13000008000) tablespace two,
partition s3 values less than (13000012000) tablespace three,
partition s4 values less than (13000016000) tablespace four,
partition s5 values less than (MAXVALUE) tablespace five
);
3.重命名表
alter table mzl rename to mzl_bak; #将原表作为备份表
alter table mzl_p rename to mzl;
4.导入原表数据到新表中。
insert /*+append*/ into mzl select * from mzl_bak;
5.删除备份表
drop table mzl_bak;
如果没有出现错误,则表明转换工作没有问题,下面,我们来谈谈分区表的查询和维护。
6.分区表查询
select * from mzl partition(s2); #查询s2分区的情况。
7.分区表分裂
alter table mzl
split partition s1 at('13000002000')
into (partition s1a compress tablespace one,partition s1);
8.分区表索引建立
create index mzl_indx on mzl(time,log)
local
(
partition s1 tablespace one,
partition s1a tablespace one,
partition s2 tablespace two,
partition s3 tablespace three,
partition s4 tablespace four,
partition s5 tablespace five
);
验证分区表索引对数据库查询的影响。
select * from mzl;
按F5键查看语句执行的开销,发现此时开销为48.此时进行的是全表扫描。
select * from mzl where time ='20090306000000';
按F5键查看语句执行的开销,发现此时开销为48.此时通过刚刚建立的索引进行查询,可见,分区索引可以提高查询效率。
本文出自 “暗淡蓝点” 博客,请务必保留此出处http://674893612.blog.51cto.com/3011730/560002
首先,末尾来看一下在Oracle数据库中采用分区表的必要性。Oracle在空间数据方面主要采用分区表的形式来平衡大表的I/O,同时避免建议超大索引占用空间,有利于数据库的读写性能。
为了能够体现分区表在执行SQL查询时的重要性,我们可以采用一张存储2000行数据的表作为案例进行试验。在这里,以mzl表为例说明:
select * from mzl;
1 13000000004 13000000004 20090305000000 0 0 20090304000000
2 13000000008 13000000008 20090305000000 0 0 20090304000000
3 13000000012 13000000012 20090305000000 0 0 20090304000000
4 13000000015 13000000015 20090305000000 0 0 20090304000000
5 13000000019 13000000019 20090305000000 0 0 20090304000000
6 13000000023 13000000023 20090305000000 0 0 20090304000000
7 13000000027 13000000027 20090305000000 0 0 20090304000000
8 13000000031 13000000031 20090305000000 0 0 20090304000000
9 13000000034 13000000034 20090305000000 0 0 20090304000000
......
这是一张普通类型的表,我们可以把它转化为我们所需要的分区表。与此同时,我们需要做好原表的备份。
1.建立表空间
为了提高数据库的读写性能,我们可以把不同分区存放在不同的表空间里,首先需要预先建立好相应的表空间,否则在创建分区表时,可能会出问题。
create tablespace one datafile 'd:\one.dbf' size 5M;
create tablespace two datafile 'd:\two.dbf' size 5M;
create tablespace three datafile 'f:\three.dbf' size 5M;
create tablespace four datafile 'f:\four.dbf' size 5M;
create tablespace five datafile 'e:\five.dbf' size 5M;
2.建立分区表
create table mzl_p
(
id char(11) not null,
sid char(11) not null,
time varchar(20),
status int,
status2 int,
log varchar(20)
)
partition by range(sid) #按照sid范围进行分区
(
partition s1 values less than (13000004000) tablespace one,
partition s2 values less than (13000008000) tablespace two,
partition s3 values less than (13000012000) tablespace three,
partition s4 values less than (13000016000) tablespace four,
partition s5 values less than (MAXVALUE) tablespace five
);
3.重命名表
alter table mzl rename to mzl_bak; #将原表作为备份表
alter table mzl_p rename to mzl;
4.导入原表数据到新表中。
insert /*+append*/ into mzl select * from mzl_bak;
5.删除备份表
drop table mzl_bak;
如果没有出现错误,则表明转换工作没有问题,下面,我们来谈谈分区表的查询和维护。
6.分区表查询
select * from mzl partition(s2); #查询s2分区的情况。
7.分区表分裂
alter table mzl
split partition s1 at('13000002000')
into (partition s1a compress tablespace one,partition s1);
8.分区表索引建立
create index mzl_indx on mzl(time,log)
local
(
partition s1 tablespace one,
partition s1a tablespace one,
partition s2 tablespace two,
partition s3 tablespace three,
partition s4 tablespace four,
partition s5 tablespace five
);
验证分区表索引对数据库查询的影响。
select * from mzl;
按F5键查看语句执行的开销,发现此时开销为48.此时进行的是全表扫描。
select * from mzl where time ='20090306000000';
按F5键查看语句执行的开销,发现此时开销为48.此时通过刚刚建立的索引进行查询,可见,分区索引可以提高查询效率。
本文出自 “暗淡蓝点” 博客,请务必保留此出处http://674893612.blog.51cto.com/3011730/560002
相关文章推荐
- 制作U盘启动系统镜像方法
- linux/OSX中“DD”命令制作ISO镜像操作系统安装U盘的方法
- 制作可启动U盘的方法
- U盘启动制作方法(未完成)
- 制作U盘版的Mozilla FirFox和Mozilla Thunderbird的简易方法
- android 镜像制作方法
- 用UltraISO制作U盘启动盘及设BIOS从U盘启动的方法
- U盘制作启动盘方法揭秘
- WinPE 制作技术文章之 —— 三种超级方法制作WinPE系统维护U盘
- 用U盘或移动硬盘安装Windows7 (超简单制作Win7安装U盘方法)
- BT4正式版U盘启动制作方法与无线密码破解
- 如何制作U盘WIN7系统安装盘以及U盘安装操作系统的方法
- U盘启动的PE系统的制作方法
- 在Ubuntu下制作ISO镜像的方法
- 镜像端口的制作方法
- 用原版XP SP3集成最新补丁制作ISO镜像的方法
- 掌握超五类双绞线的原理与制作方法
- U盘启动系统制作详细方法(MaxDOS+WinPE
- U盘启动系统制作详细方法+下载地址(MaxDOS+WinPE)
- 超级简单,三种方法制作WinPE系统维护U盘