oracle分区
oracle 分區技術:
使用分區技術,Oracle允許把一個大表分成幾個部分,每部分叫一個分區,然后把每個部分放在不同的物理磁盤,以提高整個數據庫的性能。
分區技術的優點:
1.分區技術使數據庫的可管理性變得更加容易,如:用戶可以往一個單獨的分區中裝載數據,而對其他分區沒有任何影響;用戶可以再單獨的分區上創建索引等。
2.分區可以提高表的查詢性能,SQL語句的where子句會過濾掉不需要的分區,oracle不會再掃面那些不需要的分區。
3.分區技術減少數據的不可用時間,用戶可以單獨維護一個分區中的數據,而不影響其他分區中數據的使用。
4.分區技術在數據庫級完成,幾乎不需要對應用程序做任何修改。
分區方法:
1.范圍分區--根據表中列值的范圍將整個表分成不同的部分,如按照時間進行范圍分區。
2.列表分區--使用 列表值將表劃分成幾部分。
3.哈希分區--使用哈希函數把表分成幾部分。
4.符合分區--同時使用兩種分區方法對表進行分區。
create table people
(
id number,
age int not null,
address varchar2(100))
partition by range(age)
(partition p1 values less than (10)
tablespace users,
partition p2 values? less than (20)
tablespace userdb,
partition p3 values less than (30)
tablespace users,
partition p4 values less than (70)
tablespace userdb);
create table? people3
(
id? number,
age number)
partition by hash(age)
(partition pt1 tablespace users,
partition pt2? tablespace? userdb,
partition pt3 tablespace users,
partition pt4? tablespace? userdb);
create table? people4 (name varchar2(20), city varchar2(20))
partition by list(city)
(
partition p1 values('吉林','大連') tablespace users,
partition p2 values ('成都','貴州') tablespace userdb,
partition p3 values('廣州','桂林','臺北') tablespace users);
SQL> insert into people4 (name,city)
? 2? values ('徐靜','成都');
SQL> select * from people4 partition (p2);
NAME???????????????? CITY
-------------------- --------------------
徐靜???????????????? 成都
已選擇 1 行 。
update people4 partition(p2) set name ='徐大靜' where name ='徐靜' ;
delete people4 partiton(p2) where name ='徐靜';
alter? table people4 truncate partition p2;--截斷分區
alter? table people4 merge partition p1,p2 into partition? p2;--合并分區
alter table people split partition p2 at (5) into (partition p1,partition p2);--拆分分區
alter? table people4 split partiton p3 values ('廣州','桂林') into (partition p3_part1,partition p3_part2);--拆分分區
alter table people rename partition p3_part1 to p4;--重命名分區
alter table people4 exchange partition p3_part1 with table t1;--交換分區(只是完成表中數據的遷移
alter table people4 drop partition p4;--刪除分區表中指定的分區。
轉載于:https://www.cnblogs.com/happinessqi/p/3349801.html
總結
- 上一篇: nginx php空白页 fastcgi
- 下一篇: C语言中递归什么时候能够省略return