·¢²©ÎÄ
huaihe0410

http://blog.chinaunix.net/space.php?uid=10597892

ŬÁ¦,¼á³Ö,³É°ÜÔÚ´Ë   
¸öÈË×ÊÁÏ
  • ²©¿Í·ÃÎÊ£º496298
  • ²©ÎÄÊýÁ¿£º255
  • ²©¿Í»ý·Ö£º10010
  • ²©¿ÍµÈ¼¶£ºÉϽ«
  • ×¢²áʱ¼ä£º2008-01-24 15:18:39
¶©ÔÄÎҵIJ©¿Í
  • ¶©ÔÄ
  • ¶©Ôĵ½Ïʹû
  • ¶©Ôĵ½×¥Ïº
  • ¶©Ôĵ½Google
×ÖÌå´óС£º´ó ÖРС²©ÎÄ
·ÖÀࣺ oracle·ÖÇø±í

Oracle±í·ÖÇøÑ§Ï°±Ê¼Ç

Oracle±í·ÖÇø
×Ô´Óoracle8i ¿ªÊ¼¿ÉÒÔ°ÑÒ»¸ö±í·Ö¸îΪ¶à¸öСµÄ²¿·Ö,ÕâÑù¿ÉÒÔ¶ÔoracleµÄÐÔÄÜÓÅ»¯´øÀ´ºÜ´óµÄºÃ´¦~
ÀýÈ磺¸ÄÉÆ±íµÄ²éѯÐÔÄÜ,¸ü¼ÓÈÝÒ×¹ÜÀí±íÊý¾Ý,±¸·ÝºÍ»Ö¸´²Ù×÷¸ü·½±ã
ÔÚoracle ÖзÖÇø±í ·ÖΪºÃ¼¸ÖÖµÄ(·¶Î§·ÖÇø,É¢ÁзÖÇø,×Ó·ÖÇø,Áбí·ÖÇø,Ë÷Òý·ÖÇø)ÏÂÃæÎÒÃÇÀ´ÂýÂý½éÉÜ
ÏÖÔÚÎÒÃÇÀ´½¨Á¢Ò»¸ö[·¶Î§·ÖÇø]


create table range_test (range_key date,data varchar(20)) partition by range(range_key)
(
partition part_1 values less than
            (to_date('2007-02-01','yyyy-mm-dd')),
partition part_2 values less than
           (to_date('2007-03-01','yyyy-mm-dd')),         
partition part_3 values less than
            (to_date('2007-04-01','yyyy-mm-dd')),
partition part_4 values less than
           (to_date('2007-05-01','yyyy-mm-dd'))
  )



create table RangeTable(
id int primary key,
name varchar(20),
grade int
)
partition by rang(grade)
(
partition part1 values less then(50) tablespace Part1_tb,
partition part2 values less then(MAXVALUE) tablespace Part2_tb
);


Èç¹ûgradeµÄֵСÓÚ50µÄ»° ¾Í°Ñ¼Ç¼·Åµ½ÃûΪpart1µÄ·ÖÇøµ±ÖÐ,part1·ÖÇø½«±»´æ´¢ÔÚPart1_tb±í¿Õ¼äÖÐ
ÆäËûµÄ¾Í·ÅÔÚpart2ÖÐ MAXVALUEÊÇoracleµÄ¹Ø¼ü×Ö ±íʾ×î´óÖµ
[É¢ÁзÖÇø]
create table HashTable(
id int primary key,
name varchar(20),
grade int
)
/*ÓÐÁ½ÖÖ·½Ê½,1¾ÍÊÇÖ¸¶¨·ÖÇøÊýÄ¿ºÍËùʹÓõıí¿Õ¼ä,2Ö¸¶¨ÒÔÃüÃûµÄ·ÖÇø*/
partition by hash(grade)
partitions 10 -- Ö¸¶¨·ÖÇøµÄÊýÄ¿
store in(Part1_tb,Part2_tb,Part3_tb) --Èç¹ûÖ¸¶¨µÄ·ÖÇøÊýÄ¿±È±í¿Õ¼ä¶à,·ÖÇø»áÒÔÑ­»··½Ê½·ÖÅäµ½±í¿Õ¼ä
/*------------------------------------*/
partition by rang(grade)--ÕâÖÖ·½Ê½¾ÍÊÇ Ö¸¶¨ÒÔÃüÃûµÄ·ÖÇø
(
partition part1 tablespace Part1_tb,
partition part2 tablespace Part2_tb
);
[×Ó·ÖÇø]¼´ÊÇ·ÖÇøµÄ·ÖÇø
create table ChildTable(
id int primary key,
name varchar(20),
grade int
)
partition by rang(grade)
subpartition by hash(grade)
partitions 5
(
partition part1 values less then(30) tablespace Part1_tb,
partition part2 values less then(60) tablespace Part2_tb,
partition part3 values less then(MAXVALUE) tablespace Part3_tb
);
[Áбí·ÖÇø]¸æËßoracleËùÓпÉÄܵÄÖµ
create table ListTable(
id int primary key,
name varchar(20),
area varchar(10)
)
partition by list(area)
(
partition part1 values('guangdong','beijing') tablespace Part1_tb,
partition part2 values('shanghai','nanjing') tablespace Part2_tb
);
[Ë÷Òý·ÖÇø]Ë÷ÒýÒ²¿ÉÒÔ°´ÕÕºÍ±í½øÐзÖÇøÊ±Ê¹ÓõÄÏàͬµÄÖµ·¶Î§À´·ÖÇø
create index IndexTable_index
on IndexTable(name)
local
(
partition part1 tablespace Part1_tb,
partition part2 tablespace Part2_tb
)
--local ¸æËßoracle±í IndexTableµÄÿһ¸ö·ÖÇø½¨Á¢Ò»¸ö¶ÀÁ¢µÄË÷Òý
create index IndexTable_index
on IndexTable(name)
global;
--globalΪȫ¾ÖË÷Òý È«¾ÖË÷Òý¿ÉÒÔ°üº¬¶à¸ö·ÖÇøµÄÖµ ¾Ö²¿Ë÷Òý±ÈÈ«¾ÖË÷ÒýÈÝÒ×¹ÜÀí,¶øÈ«¾ÖË÷Òý±È½Ï¿ì
×¢Òâ:²»ÄÜΪɢÁзÖÇø »òÕß ×Ó·ÖÇø´´½¨È«¾ÖË÷Òý
²éѯijһ¸ö±í·ÖÇø
select * from table partition(part1);

Ç×£¬Äú»¹Ã»ÓеǼ,Çë[µÇ¼]»ò[×¢²á]ºóÔÙ½øÐÐÆÀÂÛ