Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Range Partition Example

Range Partition Example

Ratings: (0)|Views: 7|Likes:
Published by Ajitesh Kumar Singh

More info:

Published by: Ajitesh Kumar Singh on Dec 18, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

12/18/2010

pdf

text

original

 
------------------------------------------------------------------------------- Licensed Materials - Property of IBM---- Governed under the terms of the International-- License Agreement for Non-Warranted Sample Code.---- (C) COPYRIGHT International Business Machines Corp. 2006 - 2006-- All Rights Reserved.---- US Government Users Restricted Rights - Use, duplication or-- disclosure restricted by GSA ADP Schedule Contract with IBM Corp.--------------------------------------------------------------------------------- SOURCE FILE NAME: tablepartition.db2---- SAMPLE: How to create a partitioned table.---- This sample demonstrates:---- - Various ways of creating a partitioned table using CREATE TABLE-- statement.---- SQL STATEMENTS USED:-- CREATE TABLE-- CREATE TABLESPACE-- DROP TABLE-- TERMINATE---- OUTPUT FILE: tablepartition.out (available in the online documentation)--------------------------------------------------------------------------------- For more information about the command line processor (CLP) scripts,-- see the README file.---- For information on using SQL statements, see the SQL Reference.---- For the latest information on programming, building, and running DB2-- applications, visit the DB2 Information Center:-- http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp------------------------------------------------------------------------------- Connect to database.CONNECT TO sample;-- Create DMS tablespaces.CREATE TABLESPACE tbsp1 MANAGED BY DATABASE USING (FILE 'conta' 1000);CREATE TABLESPACE tbsp2 MANAGED BY DATABASE USING (FILE 'contb' 1000);CREATE TABLESPACE tbsp3 MANAGED BY DATABASE USING (FILE 'contc' 1000);CREATE TABLESPACE tbsp4 MANAGED BY DATABASE USING (FILE 'contd' 1000);-- Creating a partitioned table on a list of tablespaces. A table 'emp_table'-- with four partitions will be created. i.e part0 is placed in tbsp1,-- part1 will be placed in tbsp2, part2 will be placed in tbsp3 and-- part3 will be placed in tbsp4.CREATE TABLE emp_table(emp_no INT) IN tbsp1, tbsp2, tbsp3, tbsp4PARTITION BY RANGE(emp_no)(STARTING 0 ENDING 9,STARTING 10 ENDING 19,STARTING 20 ENDING 29,STARTING 30 ENDING 39);
 
-- Drop the table.DROP TABLE emp_table;-- Creating a partitioned table by specifying tablespace for an individual-- data partition. A table 'emp_table' with four partitions will be created.-- i.e part0 is placed in tbsp1, part1 will be placed in tbsp2,-- part2 will be placed in tbsp3 and part3 will be placed in tbsp4.CREATE TABLE emp_table(emp_no INT)PARTITION BY RANGE(emp_no)(STARTING 0 ENDING 9 IN tbsp1,STARTING 10 ENDING 19 IN tbsp2,STARTING 20 ENDING 29 IN tbsp3,STARTING 30 ENDING 39 IN tbsp4);-- Drop the table.DROP TABLE emp_table;-- Creating a partitioned table by placing data in a Round Robin-- fashion among the tablespaces.-- A table 'emp_table' will be created with data placed in a Round Robin-- fashion among tbsp1, tbsp2, tbps3 tablespaces.CREATE TABLE emp_table(emp_no INT) IN tbsp1, tbsp2, tbsp3PARTITION BY RANGE(emp_no)(STARTING 2 ENDING 9 EVERY 2);-- Drop the table.DROP TABLE emp_table;-- Creating a partitioned table by combining both the short and the long-- forms of the syntax.CREATE TABLE emp_table(emp_no INT) IN tbsp1, tbsp2PARTITION BY RANGE(emp_no)(STARTING 10 ENDING 19 EVERY 2,STARTING 0 ENDING 9,STARTING 20 ENDING 29);-- Drop the table.DROP TABLE emp_table;-- Creating a partitioned table 'document' by using LONG IN clause to place-- the LOB data in a specified tablespace.CREATE TABLE document(sno INT, empid INT)LONG IN tbsp3, tbsp4PARTITION BY RANGE(empid) (STARTING 1 ENDING 1000 EVERY 100);-- Drop the table.DROP TABLE document;-- Creatng a partitioned table 'persons' using MINVALUE and MAXVALUE.CREATE TABLE persons (last character(15) not null,first character(15),middle character(15))PARTITION BY RANGE(last, first, middle )(part 0 starting from (MINVALUE, MINVALUE, MINVALUE),part 1 starting from ('COX', 'ELIZABETH', 'ELLEN' ) exclusive,part 2 starting from ('HARDING', 'TONYA', MINVALUE),part 3 starting from ('MACCA', MINVALUE, MINVALUE),part 4 starting from ('SMITH', MAXVALUE, MAXVALUE),part 5 starting from ('ZYZYCK', 'MARK', MAXVALUE)ending (MAXVALUE, MAXVALUE, MAXVALUE));

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->