Infolinks

Friday, 29 January 2016

partitions

Partitions

  Partition is a technique which is very useful when the database is very large and has to be accessed a number of times. One of the drawbacks of having  a partitioned table is that it cannot have user-defined types in it.


ex:

  Create table ord_mast(orderno varchar2(5) primary key,odate date,vencode varchar2(5),O_status char(1) check (O_status in ('p','c')) partition by range(orderno)
(partition om1 values less than (o010), partition om2 values less than (o020));

Inserting records into partitioned table:

  The records are stored in the partitions of a table based on the partition key specified. The partition key specified in the insert statement is compared with partition bound defined when creating the partition table.


sql> insert into ord_mast values ('o001','10-12-99','v001','p');

sql> insert into ord_mast values ('o010','10-1-99','v002','c');

sql> insert into ord_mast values ('o012','1-12-99','v001','c');


Querying the partitions individually an be performed as under.


  sql> select * from ord_mast partition(om2);


No comments:

Post a Comment