Alter table partition

hi everybody !
I have a table which also has data in it. Now, before i add some more data to this table i want to create a partition with all the existing data. Following is the error message i get when executing the altertable command.
ALTER TABLE address_header_temp
add PARTITION add_head_temp
VALUES LESS THAN (MAXVALUE);
error :-
ORA-14501: object is not partitioned
Please help me in solving this problem.
Thanks in advance
Moloy

If you wanna do it online, then, use dbms_redine package to redifine objects online. I believe this is one time process. Once you add partitions and you can drop and create partions accordingly. At least you get out of heap table to meet your requirements.
Otherwise, create another table with required partions and move data from heap (non partitoned) table to partitioned table, drop the old one and rename the new one to old one.
Jaffar

Similar Messages

  • Alter table partition based on date and status

    Hi!
    I have a strange scenario where in 100,000 to 500,000 records are created every day and records are to be maintained for 3 yrs. So to manage this table we have it partitioned based on date (so every day one new partition is created). And any partition older than 3 years are to be purged. But the catch is - the table has a 'Creation_date' and 'Close_date' parameter and as per my company's rule, I can only purge the 3 yr old data based on the 'Closed_date'. Basically we end up getting some entries with 'Close_date' that don't fall in the 3+ yr category and hence we just cannot purge the whole partition and reclaim the space.
    What would be the ideal way to partition this table to make easy maintenance!?
    eg -
    Table_1: Partition_03152006
    Col-1 Creation-date Col-2 Close-date
    AAAA 03/15/2006 BBBB 03/16/2006 I can drop this entry+
    XXXX 03/15/2006 YYYY 05/20/2006 I cannot drop this entry+
    So, I am left with non-empty partitions which I cannot purge completely. Right now, I am moving these remaining entries to another partition and purging them when they complete the 3+yr time period.
    Hope I could put in my query properly.
    NOTE: RDBMS - ORACLE 10.2.0.4 on Solaris/SPARC 64Bit
    Thanks in advance,
    Arindam
    Edited by: AB007 on Jun 19, 2009 1:15 PM

    Hi! Below is the table description and the first 5 entries of the table.
    Hi,
    Thanks for your help. Below is the table structure with the index associated with it -
    CREATE TABLE "T3TKTHEADER"
    ( "TKTNUM" VARCHAR2(13) NOT NULL ENABLE,
    "ALTTKTNUM" VARCHAR2(20),
    "CREATEDTTM" DATE,
    "CREATEUSERID" NUMBER,
    "CREATEWKGRPID" NUMBER,
    "MASTERTKTNUM" VARCHAR2(13),
    "CUSID" VARCHAR2(15),
    "CUSNAME" VARCHAR2(80),
    "CUSCNCTNAME" VARCHAR2(80),
    "CUSCNCTPHN" VARCHAR2(22),
    "ALTCUSCNCTNAME" VARCHAR2(80),
    "ALTCUSCNCTPHN" VARCHAR2(22),
    "PRTY" VARCHAR2(1),
    "SVRITY" VARCHAR2(10),
    "CURACTSEQNUM" NUMBER(*,0),
    "LASTSTASTSCHANGETM" DATE,
    "ACKNOWLEDGEFLAG" VARCHAR2(1),
    "TMGRP" NUMBER,
    "TOPGRP" NUMBER,
    "TMUSER" NUMBER,
    "TOPUSER" NUMBER,
    "RECENTTKTSCOUNT" NUMBER,
    "PRINEID" VARCHAR2(53),
    "PRINEIDSVCTYPE" VARCHAR2(128),
    "PRINEIDDETDTTM" DATE,
    "PRINEIDLOCACITY" VARCHAR2(3),
    "PRINEIDLOCASTATE" VARCHAR2(21),
    "PRINEIDLOCZCITY" VARCHAR2(3),
    "PRINEIDLOCZSTATE" VARCHAR2(21),
    "TKTTYPE" VARCHAR2(10),
    "DOMAIN" VARCHAR2(10),
    "PRODTYPE" VARCHAR2(10),
    "SYMCODE" VARCHAR2(10),
    "SYMCODEDESC" VARCHAR2(50),
    "RPTSRC" VARCHAR2(10),
    "TOTALTKTTM" NUMBER,
    "SHELLTKTTM" NUMBER(*,0),
    "OTGCLOCKON" VARCHAR2(1),
    "OTGCLOCKSEQ" VARCHAR2(5),
    "OTGTM" NUMBER,
    "ORIGNEID" VARCHAR2(80),
    "NADCODE" VARCHAR2(30),
    "NADDTTM" DATE,
    "NADCODEDESC" VARCHAR2(50),
    "OTGCAUSE" VARCHAR2(50),
    "RESLCODE" VARCHAR2(10),
    "PLATFORM" VARCHAR2(30),
    "CATEQUIP" VARCHAR2(30),
    "RESOLVEDDT" DATE,
    "CLOSEDDT" DATE,
    "PROBSUMMARY" VARCHAR2(500),
    "TOPGRPESCSTS" VARCHAR2(1),
    "TOPGRPESCLEV" VARCHAR2(2),
    "TOPGRPLASTESCTM" DATE,
    "TMGRPESCSTS" VARCHAR2(1),
    "TMGRPESCLEV" VARCHAR2(2),
    "TMGRPLASTESCTM" DATE,
    "FAIFLAG" VARCHAR2(1),
    "MSIFLAG" VARCHAR2(1),
    "CHRONICFLAG" VARCHAR2(1),
    "SLAMTTR" NUMBER,
    "TSPCODE" VARCHAR2(13),
    "DEFERREDSTARTTM" DATE,
    "TOTALDEFERREDDUR" NUMBER,
    "CURSTA" VARCHAR2(10),
    "CURSTS" VARCHAR2(10),
    "STSCOMMENT" VARCHAR2(100),
    "ACTIVEINTREFERRALS" NUMBER(*,0),
    "ACTIVEEXTREFERRALS" NUMBER(*,0),
    "NUMOFXREFS" NUMBER(*,0),
    "LASTUPDDTTM" DATE,
    "LASTUPDUSERID" NUMBER,
    "CREATEUSERID_NAME" VARCHAR2(21),
    "CREATEWKGRPID_NAME" VARCHAR2(21),
    "TMGRP_NAME" VARCHAR2(21),
    "TOPGRP_NAME" VARCHAR2(21),
    "TMUSER_NAME" VARCHAR2(21),
    "TOPUSER_NAME" VARCHAR2(21),
    "RESLCODEDESC" VARCHAR2(50),
    "RDB_INSERT_DATE" DATE,
    "CUSCNCTHOMEPHN" VARCHAR2(22),
    "CUSCNCTCELLPHN" VARCHAR2(21),
    "CUSCNCTFAXNUM" VARCHAR2(22),
    "CUSCNCTEMAIL" VARCHAR2(47),
    "ALTCUSCNCTHOMEPHN" VARCHAR2(22),
    "ALTCUSCNCTCELLPHN" VARCHAR2(21),
    "ALTCUSCNCTFAXNUM" VARCHAR2(22),
    "ALTCUSCNCTEMAIL" VARCHAR2(47),
    "CUSCNCTALTPHN" VARCHAR2(22),
    "ALTCUSCNCTALTPHN" VARCHAR2(22),
    "CREATEUSERNAME" VARCHAR2(21),
    "CREATEWKGRPNAME" VARCHAR2(21),
    "TMGRPNAME" VARCHAR2(21),
    "TOPGRPNAME" VARCHAR2(21),
    "TMUSERNAME" VARCHAR2(21),
    "TOPUSERNAME" VARCHAR2(21),
    "LASTUPDUSERNAME" VARCHAR2(21),
    "CURINTROGNAME" VARCHAR2(22),
    "CURINTROUSERNAME" VARCHAR2(22),
    "CURETTRID" NUMBER,
    "CURLECNAME" VARCHAR2(21),
    "CUREXTRODTTM" DATE,
    "RESOLVEBYUSERNAME" VARCHAR2(21),
    "RESOLVEBYWKGRPNAME" VARCHAR2(21),
    "RESOLVEDBYUSERID" NUMBER,
    "RESOLVEDBYWKGRP" NUMBER,
    "NUMOFNEIDS" NUMBER,
    "PRINEIDLOCACTYNAME" VARCHAR2(40),
    "PRINEIDLOCZCTYNAME" VARCHAR2(40),
    "SYMPTCAT" VARCHAR2(32),
    "RECEIVEDVIA" VARCHAR2(32),
    "RECENTAPPERRORCODE" VARCHAR2(10),
    "CORPID" VARCHAR2(15),
    "KEYWORDS" VARCHAR2(25),
    "SLALEVEL" VARCHAR2(1),
    "ROGSTSCOMMENT" VARCHAR2(100),
    "TOGSTSCOMMENT" VARCHAR2(100),
    "TMGSTSCOMMENT" VARCHAR2(100),
    "CUSCNCTPAGER" VARCHAR2(47),
    "ALTCUSCNCTPAGER" VARCHAR2(47),
    "METANAMETBL" VARCHAR2(10),
    "NEXTACTIONDTTM" DATE,
    "TOPWKGRPSTATUS" VARCHAR2(10),
    "INTGRPID" VARCHAR2(21),
    "INTPUBFLAG" VARCHAR2(1),
    "INTTKTNUM" VARCHAR2(30),
    "BILLEVENTFLAG" VARCHAR2(1),
    "WHN_OTGTM" NUMBER DEFAULT 0,
    "ILEC_OTGTM" NUMBER DEFAULT 0,
    "EVENTID" VARCHAR2(15),
    "NUMCIRCUITS" NUMBER,
    "TMASSIGNDTTM" DATE,
    "TOPASSIGNDTTM" DATE,
    "ALERTCUSFLAG" VARCHAR2(1),
    "MCIPRODNAME" VARCHAR2(40),
    "ALTNEID" VARCHAR2(53),
    "CONTROLSITE" VARCHAR2(14),
    "CRITICALINDICATOR" VARCHAR2(1),
    "REPORTEDBYNAME" VARCHAR2(80),
    "REPORTEDBYPHN" VARCHAR2(22),
    "REPORTEDBYCELLPHN" VARCHAR2(21),
    "REPORTEDBYEMAIL" VARCHAR2(47),
    "REPORTEDBYFAXNUM" VARCHAR2(22),
    "REPORTEDBYHOMEPHN" VARCHAR2(22),
    "REPORTEDBYPAGER" VARCHAR2(47),
    "REPORTEDBYALTPHN" VARCHAR2(22),
    "DISPATCHIND" VARCHAR2(1),
    "BILLCUSTNOTIFY" VARCHAR2(1) DEFAULT 0,
    "ACCESSID" NUMBER DEFAULT 0 NOT NULL ENABLE,
    "GARMLEVEL" VARCHAR2(10) DEFAULT 1 NOT NULL ENABLE,
    "GARMID" VARCHAR2(100) DEFAULT ' ' NOT NULL ENABLE,
    "GARMIDTYPE" VARCHAR2(50) DEFAULT ' ' NOT NULL ENABLE,
    "T1AINDICATOR" VARCHAR2(15),
    "TKTSOURCE" VARCHAR2(20),
    "SOURCETEXT" VARCHAR2(40),
    "RCOCIRCUITID" VARCHAR2(53),
    "RCOTKTNUM" VARCHAR2(13)
    ) PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255 LOGGING
    STORAGE(INITIAL 134217728 NEXT 134217728
    BUFFER_POOL DEFAULT)
    TABLESPACE "TS_MED1"
    PARTITION BY RANGE ("TKTNUM")
    (PARTITION "PART_OLD" VALUES LESS THAN ('2003080100001')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 134217728 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_OLD" NOCOMPRESS ,
    PARTITION "PART04Q1" VALUES LESS THAN ('2004033199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 52428800 NEXT 52428800 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_04_OLD" NOCOMPRESS ,
    PARTITION "PART04Q2" VALUES LESS THAN ('2004063099999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 52428800 NEXT 52428800 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_04_OLD" NOCOMPRESS ,
    PARTITION "PART04Q3" VALUES LESS THAN ('2004093099999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 52428800 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_04_OLD" NOCOMPRESS ,
    PARTITION "PART04Q4" VALUES LESS THAN ('2004123199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 52428800 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_04_OLD" NOCOMPRESS ,
    PARTITION "PART05Q1Q2" VALUES LESS THAN ('2005063199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 20971520 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEADER_05Q1Q2" NOCOMPRESS ,
    PARTITION "PART05Q3Q4" VALUES LESS THAN ('2005123199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 20971520 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_05Q3Q4" NOCOMPRESS ,
    PARTITION "PART06Q1Q2" VALUES LESS THAN ('2006063199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 20971520 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_06Q1Q2" NOCOMPRESS ,
    PARTITION "PART06Q3Q4" VALUES LESS THAN ('2006123199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_06Q3Q4" NOCOMPRESS ,
    PARTITION "PART07Q1Q2" VALUES LESS THAN ('2007063199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_07Q1Q2" NOCOMPRESS ,
    PARTITION "PART07Q3Q4" VALUES LESS THAN ('2007123199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_07Q3Q4" NOCOMPRESS ,
    PARTITION "PART08Q1Q2" VALUES LESS THAN ('2008063199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_08Q1Q2" NOCOMPRESS ,
    PARTITION "PART08Q3Q4" VALUES LESS THAN ('2008123199999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_08Q3Q4" NOCOMPRESS ,
    PARTITION "PART09Q1Q2" VALUES LESS THAN ('2009063099999')
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_09Q1Q2" NOCOMPRESS ,
    PARTITION "PART09Q3Q4" VALUES LESS THAN (MAXVALUE)
    PCTFREE 20 PCTUSED 50 INITRANS 1 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_09Q3Q4" NOCOMPRESS )
    CREATE INDEX "ETMS"."XTKTHDR9" ON "ETMS"."T3TKTHEADER" ("LASTUPDDTTM", "INTPUB
    FLAG", "CURSTS")
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(
    BUFFER_POOL DEFAULT) LOCAL
    (PARTITION "PART_OLD"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 5242880 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_TKTHEAD_OLD" ,
    PARTITION "PART04Q1"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 20971520 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_04_OLD" ,
    PARTITION "PART04Q2"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 20971520 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_04_OLD" ,
    PARTITION "PART04Q3"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 20971520 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_04_OLD" ,
    PARTITION "PART04Q4"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 20971520 NEXT 20971520 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_04_OLD" ,
    PARTITION "PART05Q1Q2"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 10485760 NEXT 10485760 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEADER_05Q1Q2" ,
    PARTITION "PART05Q3Q4"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 10485760 NEXT 10485760 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_05Q3Q4" ,
    PARTITION "PART06Q1Q2"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 5242880 NEXT 5242880 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_06Q1Q2" ,
    PARTITION "PART06Q3Q4"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_06Q3Q4" ,
    PARTITION "PART07Q1Q2"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_07Q1Q2" ,
    PARTITION "PART07Q3Q4"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_07Q3Q4" ,
    PARTITION "PART08Q1Q2"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_08Q1Q2" ,
    PARTITION "PART08Q3Q4"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_08Q3Q4" ,
    PARTITION "PART09Q1Q2"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_09Q1Q2" ,
    PARTITION "PART09Q3Q4"
    PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_IND_TKTHEAD_09Q3Q4" )
    PARALLEL 4
    DATA:
    2000120600662 06-Dec-2000 11:39:56 PM 12671 1243 UNKNOWN 5 11 0 1243 1243 -1 0 0 916 576 2675 06-Dec-2000 03:48:22 PM ANI CUSTOMER 0 0 -1 916 576 2675 0 06-Dec-2000 03:48:22 PM 0 06-Dec-2000 03:48:22 PM 0 0 0 0 CLOSED VOID 0 0 0 10-May-2001 10:17:18 PM 10873 unknown TXSAN.CSLOC TXSAN.CSLOC TXSAN.CSLOC 16-May-2008 05:50:29 PM unknowni TXSAN.CSLOC TXSAN.CSLOC TXSAN.CSLOC sburke 0 1 ALL PHONE 0 1
    2001021300976 23-Apr-2001 03:00:49 PM 50766 2113 UNKNOWN 5 2 0 2113 2113 -1 0 0 75fnode 13-Feb-2001 11:12:48 AM EQUIPMENT 0 0 1 75fnode 0 13-Feb-2001 11:12:48 AM 0 13-Feb-2001 11:12:48 AM 0 0 0 0 CLOSED VOID 0 0 0 22-May-2001 01:30:37 PM 10866 unknown MABST.3CMNOD MABST.3CMNOD MABST.3CMNOD 16-May-2008 05:50:29 PM unknown MABST.3CMNOD MABST.3CMNOD MABST.3CMNOD jcece 0 1 ALL PHONE 0 1
    2001022100287 21-Mar-2001 07:00:37 PM 62393 9974 UNKNOWN 5 14 0 9974 9974 -1 0 0 3P19S.S63.0031 20-Feb-2001 08:53:57 PM CIRCUIT CUSTOMER 0 0 0 -1 3P19S.S63.0031 0 20-Feb-2001 08:53:57 PM 0 20-Feb-2001 08:53:57 PM 0 0 0 0 CLOSED VOID 0 0 0 28-Apr-2001 03:47:18 PM 12782 mclement9486 CASAC.SSO CASAC.SSO CASAC.SSO 16-May-2008 05:50:29 PM mclement9486 CASAC.SSO CASAC.SSO CASAC.SSO unknown 0 01-Jan-1970 12:00:00 AM 1 ALL PHONE 1 N N 0 1
    2001022101367 21-Feb-2001 09:57:41 PM 42424 2935 UNKNOWN 5 4 0 2935 2935 -1 0 0 0808 105 0020 21-Feb-2001 10:46:50 AM SWITCHED CLI 0 0 -1 0808 105 0020 0 21-Feb-2001 10:46:50 AM 0 21-Feb-2001 10:46:50 AM 0 0 0 0 CLOSED VOID VOID 0 0 0 23-Apr-2001 05:54:57 PM 11063 unknown UKLN.CSCCO UKLN.CSCCO UKLN.CSCCO 16-May-2008 05:50:29 PM gharvey UKLN.CSCCO UKLN.CSCCO UKLN.CSCCO unknown 0 01-Jan-1970 12:00:00 AM 1 ALL PHONE 0 1
    Hope this helps.
    Thanks in advance,
    Arindam

  • (oracle 8i)Alter Table table coalesce partition

    Hi all,
    Need assistance in solving a problem. I have a possibly large fragemented table. I tried to run a coalese command ALTER TABLE EMPTY_COPY COALESCE PARTITION
    got an error: 'ora -14501 - object is not partitioned'
    NOt sure how to proceed, I am working in oracle 8i environment.
    Should I do :
    ALTER TABLESPACE MY_DATA COALESCE
    ALTER INDEX EMPTY_COPY_PK COALESCE
    ALTER INDEX EMPTY_COPY_PK REBUILD
    ALTER TABLE MY_DATA.EMPTY_COPY MOVE TABLESPACE NEW_DATA
    Not sure if the syntax is correct or which to use, are there any redundancies in the commands above.
    Thanks kindly for any input you may provide.

    thanks.
    My real problem is an ora 1653 'UNABLE TO EXTEND TABLE' error where I could not insert into a table. The PCT_INCREASE was at 25 and the next_extext was at 160mb. Way too large. There still looks to be l plenty of space available for an another extent but it is not being allocated.
    Would this apply?

  • What privs r required to run Alter table truncate partition update indexes?

    I rebuilt the indexes on the table. Know my problem is that when I truncate a partition on the table the unique index whic consist of the primary key fields becomes unusable which causes my to have to rebuild it after each truncate. I tried to runm the following statement from the master schema on but get
    an insufficient privs error when I use "update indexes":
    Alter table schema_name.table_name truncate partition partition_name storage update indexes;
    What priv does master need to perform statement successfully when there's data in it?
    Does using 'update indexes' needs extra priveleges?
    Thanks in Advance
    Gagan

    Hi Its Oracle 10.2.0.4 64 Bit on HP UX.
    I dont have the exact error as I got this much information only from the end user....It will be couple of hours more then he will be available again
    ok so for Truncate we need 'Drop any' privs but to use clause 'update indexes' alongwith do we need some extra privelege?
    Thanks again
    Gagan

  • High wait on Library Cache Lock while doing ALTER TABLE EXCHANGE PARTITION

    We are observing a very high wait time on "Library cache lock" while performing Exchange partition.
    Here we go
    ALTER TABLE PSALESREG EXCHANGE PARTITION P123
    WITH TABLE PBKPSALESREF WITHOUT VALIDATION
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.11 *6684.73* 2 9 2 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.11 6684.73 2 9 2 0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    library cache lock 2274 3.12 *6681.32*
    Is it a bug? is anyone there who experienced the same issue?
    Rgds

    Maurice Muller wrote:
    Hi,
    As far as I remember a exchange partition can only be done when no other query is accessing the table.
    So you should check if any other queries are executed against the table PSALESREG while you do the exchange partition. Maurice,
    queries won't block the exchange operation but continue to read from the "original", exchanged segment; this "cross-DDL" read consistency is a feature that has been introduced a long time ago.
    But any kind of (long-running) DML should effectively prevent the exchange operation. Still I would assume that this shouldn't show up as "library cache lock", but you would get an "ORA-00054: resource busy" error.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Ora 14098 Index mismatch for tables  in Alter Exchange Partition

    Hi All,
    I want to exchange data from retek schema to CONV schema. Both the table have same partition, but there is no data in CONV table.
    So I'm populating the data from retek of one particular partition into one staging table and then I'm doing exchanging partition with staging table to CONV table.
    I have created the same index and constraints for staging as there are in CONV table.
    But When I'm doing exchange partition I'm getting error Index mismatch.
    v_parition_name:='mar 2012'
    v_stmt := 'create table staging_tab_st_hist as ( select * from retek.abc_st_hist partition(' ||
    v_parition_name || ') )';
    execute immediate v_stmt;
    v_stmt := ' alter table conv.abc_st_hist exchange partition ' ||
    v_parition_name ||
    ' with table staging_tab_st_hist
    including indexes without validation';
    execute immediate v_stmt;

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    >
    Hi All,
    I want to exchange data from retek schema to CONV schema. Both the table have same partition, but there is no data in CONV table.
    So I'm populating the data from retek of one particular partition into one staging table and then I'm doing exchanging partition with staging table to CONV table.
    I have created the same index and constraints for staging as there are in CONV table.
    But When I'm doing exchange partition I'm getting error Index mismatch.
    v_parition_name:='mar 2012'
    v_stmt := 'create table staging_tab_st_hist as ( select * from retek.abc_st_hist partition(' ||
    v_parition_name || ') )';
    execute immediate v_stmt;
    v_stmt := ' alter table conv.abc_st_hist exchange partition ' ||
    v_parition_name ||
    ' with table staging_tab_st_hist
    including indexes without validation';
    execute immediate v_stmt;
    >
    I don't see any index creation on the staging table. You said this
    >
    I have created the same index and constraints for staging as there are in CONV table.
    >
    But you didn't create the indexes. When you do the CTAS (create table as select) it only creates the table with the same structure; it doesn't create ANY indexes.
    Add the code to create the necessary indexes after you populate the staging table.

  • Altering Hash Partition table

    Hi ,
    version: 10gR2
    I have a table that built with 5 hash partitions.
    Since oracle recommand that hash partition table should built with power of two
    (e.g: 2,4,8,16...) partition , i would like to rebuilt the table with 8 hash partition.
    Its a table that contain more then 100 milion records and its size is more then 2 giga.
    I understand that there isnt any: alter table .. for this kind of issue.
    Please advice me what is the best way to do this task.
    Thanks.

    use
    ALTER TABLE <table> SPLIT PARTITION <partition> AT
    (<value>) INTO ( PARTITION <partition1> TABLESPACE <tbs> , PARTITION <partition2> TABLESPACE <tbs>);to divide your partitions
    bye
    aldo

  • Sliding Window Table Partitioning Problems with RANGE RIGHT, SPLIT, MERGE using Multiple File Groups

    There is misleading information in two system views (sys.data_spaces & sys.destination_data_spaces) about the physical location of data after a partitioning MERGE and before an INDEX REBUILD operation on a partitioned table. In SQL Server 2012 SP1 CU6,
    the script below (SQLCMD mode, set DataDrive  & LogDrive variables  for the runtime environment) will create a test database with file groups and files to support a partitioned table. The partition function and scheme spread the test data across
    4 files groups, an empty partition, file group and file are maintained at the start and end of the range. A problem occurs after the SWITCH and MERGE RANGE operations, the views sys.data_spaces & sys.destination_data_spaces show the logical, not the physical,
    location of data.
    --=================================================================================
    -- PartitionLabSetup_RangeRight.sql
    -- 001. Create test database
    -- 002. Add file groups and files
    -- 003. Create partition function and schema
    -- 004. Create and populate a test table
    --=================================================================================
    USE [master]
    GO
    -- 001 - Create Test Database
    :SETVAR DataDrive "D:\SQL\Data\"
    :SETVAR LogDrive "D:\SQL\Logs\"
    :SETVAR DatabaseName "workspace"
    :SETVAR TableName "TestTable"
    -- Drop if exists and create Database
    IF DATABASEPROPERTYEX(N'$(databasename)','Status') IS NOT NULL
    BEGIN
    ALTER DATABASE $(DatabaseName) SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    DROP DATABASE $(DatabaseName)
    END
    CREATE DATABASE $(DatabaseName)
    ON
    ( NAME = $(DatabaseName)_data,
    FILENAME = N'$(DataDrive)$(DatabaseName)_data.mdf',
    SIZE = 10,
    MAXSIZE = 500,
    FILEGROWTH = 5 )
    LOG ON
    ( NAME = $(DatabaseName)_log,
    FILENAME = N'$(LogDrive)$(DatabaseName).ldf',
    SIZE = 5MB,
    MAXSIZE = 5000MB,
    FILEGROWTH = 5MB ) ;
    GO
    -- 002. Add file groups and files
    --:SETVAR DatabaseName "workspace"
    --:SETVAR TableName "TestTable"
    --:SETVAR DataDrive "D:\SQL\Data\"
    --:SETVAR LogDrive "D:\SQL\Logs\"
    DECLARE @nSQL NVARCHAR(2000) ;
    DECLARE @x INT = 1;
    WHILE @x <= 6
    BEGIN
    SELECT @nSQL =
    'ALTER DATABASE $(DatabaseName)
    ADD FILEGROUP $(TableName)_fg' + RTRIM(CAST(@x AS CHAR(5))) + ';
    ALTER DATABASE $(DatabaseName)
    ADD FILE
    NAME= ''$(TableName)_f' + CAST(@x AS CHAR(5)) + ''',
    FILENAME = ''$(DataDrive)\$(TableName)_f' + RTRIM(CAST(@x AS CHAR(5))) + '.ndf''
    TO FILEGROUP $(TableName)_fg' + RTRIM(CAST(@x AS CHAR(5))) + ';'
    EXEC sp_executeSQL @nSQL;
    SET @x = @x + 1;
    END
    -- 003. Create partition function and schema
    --:SETVAR TableName "TestTable"
    --:SETVAR DatabaseName "workspace"
    USE $(DatabaseName);
    CREATE PARTITION FUNCTION $(TableName)_func (int)
    AS RANGE RIGHT FOR VALUES
    0,
    15,
    30,
    45,
    60
    CREATE PARTITION SCHEME $(TableName)_scheme
    AS
    PARTITION $(TableName)_func
    TO
    $(TableName)_fg1,
    $(TableName)_fg2,
    $(TableName)_fg3,
    $(TableName)_fg4,
    $(TableName)_fg5,
    $(TableName)_fg6
    -- Create TestTable
    --:SETVAR TableName "TestTable"
    --:SETVAR BackupDrive "D:\SQL\Backups\"
    --:SETVAR DatabaseName "workspace"
    CREATE TABLE [dbo].$(TableName)(
    [Partition_PK] [int] NOT NULL,
    [GUID_PK] [uniqueidentifier] NOT NULL,
    [CreateDate] [datetime] NULL,
    [CreateServer] [nvarchar](50) NULL,
    [RandomNbr] [int] NULL,
    CONSTRAINT [PK_$(TableName)] PRIMARY KEY CLUSTERED
    [Partition_PK] ASC,
    [GUID_PK] ASC
    ) ON $(TableName)_scheme(Partition_PK)
    ) ON $(TableName)_scheme(Partition_PK)
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_GUID_PK] DEFAULT (newid()) FOR [GUID_PK]
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_CreateServer] DEFAULT (@@servername) FOR [CreateServer]
    -- 004. Create and populate a test table
    -- Load TestTable Data - Seconds 0-59 are used as the Partitoning Key
    --:SETVAR TableName "TestTable"
    SET NOCOUNT ON;
    DECLARE @Now DATETIME = GETDATE()
    WHILE @Now > DATEADD(minute,-1,GETDATE())
    BEGIN
    INSERT INTO [dbo].$(TableName)
    ([Partition_PK]
    ,[RandomNbr])
    VALUES
    DATEPART(second,GETDATE())
    ,ROUND((RAND() * 100),0)
    END
    -- Confirm table partitioning - http://lextonr.wordpress.com/tag/sys-destination_data_spaces/
    SELECT
    N'DatabaseName' = DB_NAME()
    , N'SchemaName' = s.name
    , N'TableName' = o.name
    , N'IndexName' = i.name
    , N'IndexType' = i.type_desc
    , N'PartitionScheme' = ps.name
    , N'DataSpaceName' = ds.name
    , N'DataSpaceType' = ds.type_desc
    , N'PartitionFunction' = pf.name
    , N'PartitionNumber' = dds.destination_id
    , N'BoundaryValue' = prv.value
    , N'RightBoundary' = pf.boundary_value_on_right
    , N'PartitionFileGroup' = ds2.name
    , N'RowsOfData' = p.[rows]
    FROM
    sys.objects AS o
    INNER JOIN sys.schemas AS s
    ON o.[schema_id] = s.[schema_id]
    INNER JOIN sys.partitions AS p
    ON o.[object_id] = p.[object_id]
    INNER JOIN sys.indexes AS i
    ON p.[object_id] = i.[object_id]
    AND p.index_id = i.index_id
    INNER JOIN sys.data_spaces AS ds
    ON i.data_space_id = ds.data_space_id
    INNER JOIN sys.partition_schemes AS ps
    ON ds.data_space_id = ps.data_space_id
    INNER JOIN sys.partition_functions AS pf
    ON ps.function_id = pf.function_id
    LEFT OUTER JOIN sys.partition_range_values AS prv
    ON pf.function_id = prv.function_id
    AND p.partition_number = prv.boundary_id
    LEFT OUTER JOIN sys.destination_data_spaces AS dds
    ON ps.data_space_id = dds.partition_scheme_id
    AND p.partition_number = dds.destination_id
    LEFT OUTER JOIN sys.data_spaces AS ds2
    ON dds.data_space_id = ds2.data_space_id
    ORDER BY
    DatabaseName
    ,SchemaName
    ,TableName
    ,IndexName
    ,PartitionNumber
    --=================================================================================
    -- SECTION 2 - SWITCH OUT
    -- 001 - Create TestTableOut
    -- 002 - Switch out partition in range 0-14
    -- 003 - Merge range 0 -29
    -- 001. TestTableOut
    :SETVAR TableName "TestTable"
    IF OBJECT_ID('dbo.$(TableName)Out') IS NOT NULL
    DROP TABLE [dbo].[$(TableName)Out]
    CREATE TABLE [dbo].[$(TableName)Out](
    [Partition_PK] [int] NOT NULL,
    [GUID_PK] [uniqueidentifier] NOT NULL,
    [CreateDate] [datetime] NULL,
    [CreateServer] [nvarchar](50) NULL,
    [RandomNbr] [int] NULL,
    CONSTRAINT [PK_$(TableName)Out] PRIMARY KEY CLUSTERED
    [Partition_PK] ASC,
    [GUID_PK] ASC
    ) ON $(TableName)_fg2;
    GO
    -- 002 - Switch out partition in range 0-14
    --:SETVAR TableName "TestTable"
    ALTER TABLE dbo.$(TableName)
    SWITCH PARTITION 2 TO dbo.$(TableName)Out;
    -- 003 - Merge range 0 - 29
    --:SETVAR TableName "TestTable"
    ALTER PARTITION FUNCTION $(TableName)_func()
    MERGE RANGE (15);
    -- Confirm table partitioning
    -- Original source of this query - http://lextonr.wordpress.com/tag/sys-destination_data_spaces/
    SELECT
    N'DatabaseName' = DB_NAME()
    , N'SchemaName' = s.name
    , N'TableName' = o.name
    , N'IndexName' = i.name
    , N'IndexType' = i.type_desc
    , N'PartitionScheme' = ps.name
    , N'DataSpaceName' = ds.name
    , N'DataSpaceType' = ds.type_desc
    , N'PartitionFunction' = pf.name
    , N'PartitionNumber' = dds.destination_id
    , N'BoundaryValue' = prv.value
    , N'RightBoundary' = pf.boundary_value_on_right
    , N'PartitionFileGroup' = ds2.name
    , N'RowsOfData' = p.[rows]
    FROM
    sys.objects AS o
    INNER JOIN sys.schemas AS s
    ON o.[schema_id] = s.[schema_id]
    INNER JOIN sys.partitions AS p
    ON o.[object_id] = p.[object_id]
    INNER JOIN sys.indexes AS i
    ON p.[object_id] = i.[object_id]
    AND p.index_id = i.index_id
    INNER JOIN sys.data_spaces AS ds
    ON i.data_space_id = ds.data_space_id
    INNER JOIN sys.partition_schemes AS ps
    ON ds.data_space_id = ps.data_space_id
    INNER JOIN sys.partition_functions AS pf
    ON ps.function_id = pf.function_id
    LEFT OUTER JOIN sys.partition_range_values AS prv
    ON pf.function_id = prv.function_id
    AND p.partition_number = prv.boundary_id
    LEFT OUTER JOIN sys.destination_data_spaces AS dds
    ON ps.data_space_id = dds.partition_scheme_id
    AND p.partition_number = dds.destination_id
    LEFT OUTER JOIN sys.data_spaces AS ds2
    ON dds.data_space_id = ds2.data_space_id
    ORDER BY
    DatabaseName
    ,SchemaName
    ,TableName
    ,IndexName
    ,PartitionNumber  
    The table below shows the results of the ‘Confirm Table Partitioning’ query, before and after the MERGE.
    The T-SQL code below illustrates the problem.
    -- PartitionLab_RangeRight
    USE workspace;
    DROP TABLE dbo.TestTableOut;
    USE master;
    ALTER DATABASE workspace
    REMOVE FILE TestTable_f3 ;
    -- ERROR
    --Msg 5042, Level 16, State 1, Line 1
    --The file 'TestTable_f3 ' cannot be removed because it is not empty.
    ALTER DATABASE workspace
    REMOVE FILE TestTable_f2 ;
    -- Works surprisingly!!
    use workspace;
    ALTER INDEX [PK_TestTable] ON [dbo].[TestTable] REBUILD PARTITION = 2;
    --Msg 622, Level 16, State 3, Line 2
    --The filegroup "TestTable_fg2" has no files assigned to it. Tables, indexes, text columns, ntext columns, and image columns cannot be populated on this filegroup until a file is added.
    --The statement has been terminated.
    If you run ALTER INDEX REBUILD before trying to remove files from File Group 3, it works. Rerun the database setup script then the code below.
    -- RANGE RIGHT
    -- Rerun PartitionLabSetup_RangeRight.sql before the code below
    USE workspace;
    DROP TABLE dbo.TestTableOut;
    ALTER INDEX [PK_TestTable] ON [dbo].[TestTable] REBUILD PARTITION = 2;
    USE master;
    ALTER DATABASE workspace
    REMOVE FILE TestTable_f3;
    -- Works as expected!!
    The file in File Group 2 appears to contain data but it can be dropped. Although the system views are reporting the data in File Group 2, it still physically resides in File Group 3 and isn’t moved until the index is rebuilt. The RANGE RIGHT function means
    the left file group (File Group 2) is retained when splitting ranges.
    RANGE LEFT would have retained the data in File Group 3 where it already resided, no INDEX REBUILD is necessary to effectively complete the MERGE operation. The script below implements the same partitioning strategy (data distribution between partitions)
    on the test table but uses different boundary definitions and RANGE LEFT.
    --=================================================================================
    -- PartitionLabSetup_RangeLeft.sql
    -- 001. Create test database
    -- 002. Add file groups and files
    -- 003. Create partition function and schema
    -- 004. Create and populate a test table
    --=================================================================================
    USE [master]
    GO
    -- 001 - Create Test Database
    :SETVAR DataDrive "D:\SQL\Data\"
    :SETVAR LogDrive "D:\SQL\Logs\"
    :SETVAR DatabaseName "workspace"
    :SETVAR TableName "TestTable"
    -- Drop if exists and create Database
    IF DATABASEPROPERTYEX(N'$(databasename)','Status') IS NOT NULL
    BEGIN
    ALTER DATABASE $(DatabaseName) SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    DROP DATABASE $(DatabaseName)
    END
    CREATE DATABASE $(DatabaseName)
    ON
    ( NAME = $(DatabaseName)_data,
    FILENAME = N'$(DataDrive)$(DatabaseName)_data.mdf',
    SIZE = 10,
    MAXSIZE = 500,
    FILEGROWTH = 5 )
    LOG ON
    ( NAME = $(DatabaseName)_log,
    FILENAME = N'$(LogDrive)$(DatabaseName).ldf',
    SIZE = 5MB,
    MAXSIZE = 5000MB,
    FILEGROWTH = 5MB ) ;
    GO
    -- 002. Add file groups and files
    --:SETVAR DatabaseName "workspace"
    --:SETVAR TableName "TestTable"
    --:SETVAR DataDrive "D:\SQL\Data\"
    --:SETVAR LogDrive "D:\SQL\Logs\"
    DECLARE @nSQL NVARCHAR(2000) ;
    DECLARE @x INT = 1;
    WHILE @x <= 6
    BEGIN
    SELECT @nSQL =
    'ALTER DATABASE $(DatabaseName)
    ADD FILEGROUP $(TableName)_fg' + RTRIM(CAST(@x AS CHAR(5))) + ';
    ALTER DATABASE $(DatabaseName)
    ADD FILE
    NAME= ''$(TableName)_f' + CAST(@x AS CHAR(5)) + ''',
    FILENAME = ''$(DataDrive)\$(TableName)_f' + RTRIM(CAST(@x AS CHAR(5))) + '.ndf''
    TO FILEGROUP $(TableName)_fg' + RTRIM(CAST(@x AS CHAR(5))) + ';'
    EXEC sp_executeSQL @nSQL;
    SET @x = @x + 1;
    END
    -- 003. Create partition function and schema
    --:SETVAR TableName "TestTable"
    --:SETVAR DatabaseName "workspace"
    USE $(DatabaseName);
    CREATE PARTITION FUNCTION $(TableName)_func (int)
    AS RANGE LEFT FOR VALUES
    -1,
    14,
    29,
    44,
    59
    CREATE PARTITION SCHEME $(TableName)_scheme
    AS
    PARTITION $(TableName)_func
    TO
    $(TableName)_fg1,
    $(TableName)_fg2,
    $(TableName)_fg3,
    $(TableName)_fg4,
    $(TableName)_fg5,
    $(TableName)_fg6
    -- Create TestTable
    --:SETVAR TableName "TestTable"
    --:SETVAR BackupDrive "D:\SQL\Backups\"
    --:SETVAR DatabaseName "workspace"
    CREATE TABLE [dbo].$(TableName)(
    [Partition_PK] [int] NOT NULL,
    [GUID_PK] [uniqueidentifier] NOT NULL,
    [CreateDate] [datetime] NULL,
    [CreateServer] [nvarchar](50) NULL,
    [RandomNbr] [int] NULL,
    CONSTRAINT [PK_$(TableName)] PRIMARY KEY CLUSTERED
    [Partition_PK] ASC,
    [GUID_PK] ASC
    ) ON $(TableName)_scheme(Partition_PK)
    ) ON $(TableName)_scheme(Partition_PK)
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_GUID_PK] DEFAULT (newid()) FOR [GUID_PK]
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
    ALTER TABLE [dbo].$(TableName) ADD CONSTRAINT [DF_$(TableName)_CreateServer] DEFAULT (@@servername) FOR [CreateServer]
    -- 004. Create and populate a test table
    -- Load TestTable Data - Seconds 0-59 are used as the Partitoning Key
    --:SETVAR TableName "TestTable"
    SET NOCOUNT ON;
    DECLARE @Now DATETIME = GETDATE()
    WHILE @Now > DATEADD(minute,-1,GETDATE())
    BEGIN
    INSERT INTO [dbo].$(TableName)
    ([Partition_PK]
    ,[RandomNbr])
    VALUES
    DATEPART(second,GETDATE())
    ,ROUND((RAND() * 100),0)
    END
    -- Confirm table partitioning - http://lextonr.wordpress.com/tag/sys-destination_data_spaces/
    SELECT
    N'DatabaseName' = DB_NAME()
    , N'SchemaName' = s.name
    , N'TableName' = o.name
    , N'IndexName' = i.name
    , N'IndexType' = i.type_desc
    , N'PartitionScheme' = ps.name
    , N'DataSpaceName' = ds.name
    , N'DataSpaceType' = ds.type_desc
    , N'PartitionFunction' = pf.name
    , N'PartitionNumber' = dds.destination_id
    , N'BoundaryValue' = prv.value
    , N'RightBoundary' = pf.boundary_value_on_right
    , N'PartitionFileGroup' = ds2.name
    , N'RowsOfData' = p.[rows]
    FROM
    sys.objects AS o
    INNER JOIN sys.schemas AS s
    ON o.[schema_id] = s.[schema_id]
    INNER JOIN sys.partitions AS p
    ON o.[object_id] = p.[object_id]
    INNER JOIN sys.indexes AS i
    ON p.[object_id] = i.[object_id]
    AND p.index_id = i.index_id
    INNER JOIN sys.data_spaces AS ds
    ON i.data_space_id = ds.data_space_id
    INNER JOIN sys.partition_schemes AS ps
    ON ds.data_space_id = ps.data_space_id
    INNER JOIN sys.partition_functions AS pf
    ON ps.function_id = pf.function_id
    LEFT OUTER JOIN sys.partition_range_values AS prv
    ON pf.function_id = prv.function_id
    AND p.partition_number = prv.boundary_id
    LEFT OUTER JOIN sys.destination_data_spaces AS dds
    ON ps.data_space_id = dds.partition_scheme_id
    AND p.partition_number = dds.destination_id
    LEFT OUTER JOIN sys.data_spaces AS ds2
    ON dds.data_space_id = ds2.data_space_id
    ORDER BY
    DatabaseName
    ,SchemaName
    ,TableName
    ,IndexName
    ,PartitionNumber
    --=================================================================================
    -- SECTION 2 - SWITCH OUT
    -- 001 - Create TestTableOut
    -- 002 - Switch out partition in range 0-14
    -- 003 - Merge range 0 -29
    -- 001. TestTableOut
    :SETVAR TableName "TestTable"
    IF OBJECT_ID('dbo.$(TableName)Out') IS NOT NULL
    DROP TABLE [dbo].[$(TableName)Out]
    CREATE TABLE [dbo].[$(TableName)Out](
    [Partition_PK] [int] NOT NULL,
    [GUID_PK] [uniqueidentifier] NOT NULL,
    [CreateDate] [datetime] NULL,
    [CreateServer] [nvarchar](50) NULL,
    [RandomNbr] [int] NULL,
    CONSTRAINT [PK_$(TableName)Out] PRIMARY KEY CLUSTERED
    [Partition_PK] ASC,
    [GUID_PK] ASC
    ) ON $(TableName)_fg2;
    GO
    -- 002 - Switch out partition in range 0-14
    --:SETVAR TableName "TestTable"
    ALTER TABLE dbo.$(TableName)
    SWITCH PARTITION 2 TO dbo.$(TableName)Out;
    -- 003 - Merge range 0 - 29
    :SETVAR TableName "TestTable"
    ALTER PARTITION FUNCTION $(TableName)_func()
    MERGE RANGE (14);
    -- Confirm table partitioning
    -- Original source of this query - http://lextonr.wordpress.com/tag/sys-destination_data_spaces/
    SELECT
    N'DatabaseName' = DB_NAME()
    , N'SchemaName' = s.name
    , N'TableName' = o.name
    , N'IndexName' = i.name
    , N'IndexType' = i.type_desc
    , N'PartitionScheme' = ps.name
    , N'DataSpaceName' = ds.name
    , N'DataSpaceType' = ds.type_desc
    , N'PartitionFunction' = pf.name
    , N'PartitionNumber' = dds.destination_id
    , N'BoundaryValue' = prv.value
    , N'RightBoundary' = pf.boundary_value_on_right
    , N'PartitionFileGroup' = ds2.name
    , N'RowsOfData' = p.[rows]
    FROM
    sys.objects AS o
    INNER JOIN sys.schemas AS s
    ON o.[schema_id] = s.[schema_id]
    INNER JOIN sys.partitions AS p
    ON o.[object_id] = p.[object_id]
    INNER JOIN sys.indexes AS i
    ON p.[object_id] = i.[object_id]
    AND p.index_id = i.index_id
    INNER JOIN sys.data_spaces AS ds
    ON i.data_space_id = ds.data_space_id
    INNER JOIN sys.partition_schemes AS ps
    ON ds.data_space_id = ps.data_space_id
    INNER JOIN sys.partition_functions AS pf
    ON ps.function_id = pf.function_id
    LEFT OUTER JOIN sys.partition_range_values AS prv
    ON pf.function_id = prv.function_id
    AND p.partition_number = prv.boundary_id
    LEFT OUTER JOIN sys.destination_data_spaces AS dds
    ON ps.data_space_id = dds.partition_scheme_id
    AND p.partition_number = dds.destination_id
    LEFT OUTER JOIN sys.data_spaces AS ds2
    ON dds.data_space_id = ds2.data_space_id
    ORDER BY
    DatabaseName
    ,SchemaName
    ,TableName
    ,IndexName
    ,PartitionNumber
    The table below shows the results of the ‘Confirm Table Partitioning’ query, before and after the MERGE.
    The data in the File and File Group to be dropped (File Group 2) has already been switched out; File Group 3 contains the data so no index rebuild is needed to move data and complete the MERGE.
    RANGE RIGHT would not be a problem in a ‘Sliding Window’ if the same file group is used for all partitions, when they are created and dropped it introduces a dependency on full index rebuilds. Larger tables are typically partitioned and a full index rebuild
    might be an expensive operation. I’m not sure how a RANGE RIGHT partitioning strategy could be implemented, with an ascending partitioning key, using multiple file groups without having to move data. Using a single file group (multiple files) for all partitions
    within a table would avoid physically moving data between file groups; no index rebuild would be necessary to complete a MERGE and system views would accurately reflect the physical location of data. 
    If a RANGE RIGHT partition function is used, the data is physically in the wrong file group after the MERGE assuming a typical ascending partitioning key, and the 'Data Spaces' system views might be misleading. Thanks to Manuj and Chris for a lot of help
    investigating this.
    NOTE 10/03/2014 - The solution
    The solution is so easy it's embarrassing, I was using the wrong boundary points for the MERGE (both RANGE LEFT & RANGE RIGHT) to get rid of historic data.
    -- Wrong Boundary Point Range Right
    --ALTER PARTITION FUNCTION $(TableName)_func()
    --MERGE RANGE (15);
    -- Wrong Boundary Point Range Left
    --ALTER PARTITION FUNCTION $(TableName)_func()
    --MERGE RANGE (14);
    -- Correct Boundary Pounts for MERGE
    ALTER PARTITION FUNCTION $(TableName)_func()
    MERGE RANGE (0); -- or -1 for RANGE LEFT
    The empty, switched out partition (on File Group 2) is then MERGED with the empty partition maintained at the start of the range and no data movement is necessary. I retract the suggestion that a problem exists with RANGE RIGHT Sliding Windows using multiple
    file groups and apologize :-)

    Hi Paul Brewer,
    Thanks for your post and glad to hear that the issue is resolved. It is kind of you post a reply to share your solution. That way, other community members could benefit from your sharing.
    Regards.
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • 1.5 Edit Table Partitions - Can not edit Values Less than Field

    When editing (or more importantly to me) creating new partitions through the GUI. This slao was an issue w/1.2.1 that I recently discovered, I was hoping that it would have gotten fixed in 1.5

    Just to confirm this is only a problem when editing a table? It seems fine when creating a table from scratch.
    The field is disabled when editing an existing partition because there isn't (as far as I can tell) an ALTER TABLE clause for changing the less than value of a range partition.
    It's a bug that when you create a new partition, while editing a table, the field is still disabled. I'll log it now.

  • Table partitioning best practices

    Just looking for some ideas.
    We have a large information warehouse table that we are looking to partition on 'service_period' id. We have been requested to partition on every month of every year which right now will create approximately 70 partitions. The other problem is that this is a rolling or dynamic partition meaning we will have a 'new' partition vale with each new month. I understand in 11g there is a rolling partition functionality but we are not there yet.
    So right now we are looking for a best practice for this scenario. We are thinking of possibly creating a partition on each year and indexing on the service period within each partition, maybe hash partitioning on the service period id (although does not seem to group the service periods distinct within each partition), somehow creating the partition dynamically via pl/sql (creating the table with a basic partition and then running an alter table on the data creating the proper number of partitions within a list partition.
    I am also wondering if there is a point of too many partitions on a table. I am thinking 70 may be a little extreme but not sure. We are going to do some performance testing but would be nice to hear from the community. We have 5,000,000 over approx 70 partitions giving us approx 70,000 records per partition. The other option would be to create the partition based on year and then apply an index over top on the service period to reduce the number of partitions.
    Thanks in advance,
    Bruce Carson

    This is not a lot of data, so the effort of partitioning may not be worth the benefit you receive. 70 partitions is not unreasonable. Do you have performance problems ? Do the majority of your queries reference service_period ? Do you have a lot of full table scans ?
    Partitioning strategies depend on the queries you plan to run, your data distributions, and your purge / archival strategy.
    Think about whether you should pre-create partitions for years in advance. Think about whether you should put every partition in a seperate tablespace for easy purging and archival. Think about what indexing you will use (can you use local indexes, or do you need global ?) Think about what data changes are happening ? Are they all on the newest data ? Can you compress older partitions with PCT_FREE 0 to improve performance ?

  • Fact and dimension table partition

    My team is implementing new data-warehouse. I would like to know that when  should we plan to do partition of fact and dimension table, before data comes in or after?

    Hi,
    It is recommended to partition Fact table (Where we will have huge data). Automate the partition so that each day it will create a new partition to hold latest data (Split the previous partition into 2). Best practice is to create partition on transaction
    timestamps so load the incremental data into a empty table called (Table_IN) and then Switch that data into main table (Table). Make sure your tables (Table and Table_IN) should be on one file group.
    Refer below content for detailed info
    Designing and Administrating Partitions in SQL Server 2012
    A popular method of better managing large and active tables and indexes is the use of partitioning. Partitioning is a feature for segregating I/O workload within
    SQL Server database so that I/O can be better balanced against available I/O subsystems while providing better user response time, lower I/O latency, and faster backups and recovery. By partitioning tables and indexes across multiple filegroups, data retrieval
    and management is much quicker because only subsets of the data are used, meanwhile ensuring that the integrity of the database as a whole remains intact.
    Tip
    Partitioning is typically used for administrative or certain I/O performance scenarios. However, partitioning can also speed up some queries by enabling
    lock escalation to a single partition, rather than to an entire table. You must allow lock escalation to move up to the partition level by setting it with either the Lock Escalation option of Database Options page in SSMS or by using the LOCK_ESCALATION option
    of the ALTER TABLE statement.
    After a table or index is partitioned, data is stored horizontally across multiple filegroups, so groups of data are mapped to individual partitions. Typical
    scenarios for partitioning include large tables that become very difficult to manage, tables that are suffering performance degradation because of excessive I/O or blocking locks, table-centric maintenance processes that exceed the available time for maintenance,
    and moving historical data from the active portion of a table to a partition with less activity.
    Partitioning tables and indexes warrants a bit of planning before putting them into production. The usual approach to partitioning a table or index follows these
    steps:
    1. Create
    the filegroup(s) and file(s) used to hold the partitions defined by the partitioning scheme.
    2. Create
    a partition function to map the rows of the table or index to specific partitions based on the values in a specified column. A very common partitioning function is based on the creation date of the record.
    3. Create
    a partitioning scheme to map the partitions of the partitioned table to the specified filegroup(s) and, thereby, to specific locations on the Windows file system.
    4. Create
    the table or index (or ALTER an existing table or index) by specifying the partition scheme as the storage location for the partitioned object.
    Although Transact-SQL commands are available to perform every step described earlier, the Create Partition Wizard makes the entire process quick and easy through
    an intuitive point-and-click interface. The next section provides an overview of using the Create Partition Wizard in SQL Server 2012, and an example later in this section shows the Transact-SQL commands.
    Leveraging the Create Partition Wizard to Create Table and Index Partitions
    The Create Partition Wizard can be used to divide data in large tables across multiple filegroups to increase performance and can be invoked by right-clicking
    any table or index, selecting Storage, and then selecting Create Partition. The first step is to identify which columns to partition by reviewing all the columns available in the Available Partitioning Columns section located on the Select a Partitioning Column
    dialog box, as displayed in Figure 3.13. This screen also includes additional options such as the following:
    Figure 3.13. Selecting a partitioning column.
    The next screen is called Select a Partition Function. This page is used for specifying the partition function where the data will be partitioned. The options
    include using an existing partition or creating a new partition. The subsequent page is called New Partition Scheme. Here a DBA will conduct a mapping of the rows selected of tables being partitioned to a desired filegroup. Either a new partition scheme should
    be used or a new one needs to be created. The final screen is used for doing the actual mapping. On the Map Partitions page, specify the partitions to be used for each partition and then enter a range for the values of the partitions. The
    ranges and settings on the grid include the following:
    Note
    By opening the Set Boundary Values dialog box, a DBA can set boundary values based on dates (for example, partition everything in a column after a specific
    date). The data types are based on dates.
    Designing table and index partitions is a DBA task that typically requires a joint effort with the database development team. The DBA must have a strong understanding
    of the database, tables, and columns to make the correct choices for partitioning. For more information on partitioning, review Books Online.
    Enhancements to Partitioning in SQL Server 2012
    SQL Server 2012 now supports as many as 15,000 partitions. When using more than 1,000 partitions, Microsoft recommends that the instance of SQL Server have at
    least 16Gb of available memory. This recommendation particularly applies to partitioned indexes, especially those that are not aligned with the base table or with the clustered index of the table. Other Data Manipulation Language statements (DML) and Data
    Definition Language statements (DDL) may also run short of memory when processing on a large number of partitions.
    Certain DBCC commands may take longer to execute when processing a large number of partitions. On the other hand, a few DBCC commands can be scoped to the partition
    level and, if so, can be used to perform their function on a subset of data in the partitioned table.
    Queries may also benefit from a new query engine enhancement called partition elimination. SQL Server uses partition enhancement automatically if it is available.
    Here’s how it works. Assume a table has four partitions, with all the data for customers whose names begin with R, S, or T in the third partition. If a query’s WHERE clause
    filters on customer name looking for ‘System%’, the query engine knows that it needs only to partition three to answer
    the request. Thus, it might greatly reduce I/O for that query. On the other hand, some queries might take longer if there are more than 1,000 partitions and the query is not able to perform partition elimination.
    Finally, SQL Server 2012 introduces some changes and improvements to the algorithms used to calculate partitioned index statistics. Primarily, SQL Server 2012
    samples rows in a partitioned index when it is created or rebuilt, rather than scanning all available rows. This may sometimes result in somewhat different query behavior compared to the same queries running on SQL Server 2012.
    Administrating Data Using Partition Switching
    Partitioning is useful to access and manage a subset of data while losing none of the integrity of the entire data set. There is one limitation, though. When
    a partition is created on an existing table, new data is added to a specific partition or to the default partition if none is specified. That means the default partition might grow unwieldy if it is left unmanaged. (This concept is similar to how a clustered
    index needs to be rebuilt from time to time to reestablish its fill factor setting.)
    Switching partitions is a fast operation because no physical movement of data takes place. Instead, only the metadata pointers to the physical data are altered.
    You can alter partitions using SQL Server Management Studio or with the ALTER TABLE...SWITCH
    Transact-SQL statement. Both options enable you to ensure partitions are
    well maintained. For example, you can transfer subsets of data between partitions, move tables between partitions, or combine partitions together. Because the ALTER TABLE...SWITCH statement
    does not actually move the data, a few prerequisites must be in place:
    • Partitions must use the same column when switching between two partitions.
    • The source and target table must exist prior to the switch and must be on the same filegroup, along with their corresponding indexes,
    index partitions, and indexed view partitions.
    • The target partition must exist prior to the switch, and it must be empty, whether adding a table to an existing partitioned table
    or moving a partition from one table to another. The same holds true when moving a partitioned table to a nonpartitioned table structure.
    • The source and target tables must have the same columns in identical order with the same names, data types, and data type attributes
    (length, precision, scale, and nullability). Computed columns must have identical syntax, as well as primary key constraints. The tables must also have the same settings for ANSI_NULLS and QUOTED_IDENTIFIER properties.
    Clustered and nonclustered indexes must be identical. ROWGUID properties
    and XML schemas must match. Finally, settings for in-row data storage must also be the same.
    • The source and target tables must have matching nullability on the partitioning column. Although both NULL and NOT
    NULL are supported, NOT
    NULL is strongly recommended.
    Likewise, the ALTER TABLE...SWITCH statement
    will not work under certain circumstances:
    • Full-text indexes, XML indexes, and old-fashioned SQL Server rules are not allowed (though CHECK constraints
    are allowed).
    • Tables in a merge replication scheme are not allowed. Tables in a transactional replication scheme are allowed with special caveats.
    Triggers are allowed on tables but must not fire during the switch.
    • Indexes on the source and target table must reside on the same partition as the tables themselves.
    • Indexed views make partition switching difficult and have a lot of extra rules about how and when they can be switched. Refer to
    the SQL Server Books Online if you want to perform partition switching on tables containing indexed views.
    • Referential integrity can impact the use of partition switching. First, foreign keys on other tables cannot reference the source
    table. If the source table holds the primary key, it cannot have a primary or foreign key relationship with the target table. If the target table holds the foreign key, it cannot have a primary or foreign key relationship with the source table.
    In summary, simple tables can easily accommodate partition switching. The more complexity a source or target table exhibits, the more likely that careful planning
    and extra work will be required to even make partition switching possible, let alone efficient.
    Here’s an example where we create a partitioned table using a previously created partition scheme, called Date_Range_PartScheme1.
    We then create a new, nonpartitioned table identical to the partitioned table residing on the same filegroup. We finish up switching the data from the partitioned table into the nonpartitioned table:
    CREATE TABLE TransactionHistory_Partn1 (Xn_Hst_ID int, Xn_Type char(10)) ON Date_Range_PartScheme1 (Xn_Hst_ID) ; GO CREATE TABLE TransactionHistory_No_Partn (Xn_Hst_ID int, Xn_Type
    char(10)) ON main_filegroup ; GO ALTER TABLE TransactionHistory_Partn1 SWITCH partition1 TO TransactionHistory_No_Partn; GO
    The next section shows how to use a more sophisticated, but very popular, approach to partition switching called a sliding
    window partition.
    Example and Best Practices for Managing Sliding Window Partitions
    Assume that our AdventureWorks business is booming. The sales staff, and by extension the AdventureWorks2012 database, is very busy. We noticed over time that
    the TransactionHistory table is very active as sales transactions are first entered and are still very active over their first month in the database. But the older the transactions are, the less activity they see. Consequently, we’d like to automatically group
    transactions into four partitions per year, basically containing one quarter of the year’s data each, in a rolling partitioning. Any transaction older than one year will be purged or archived.
    The answer to a scenario like the preceding one is called a sliding window partition because
    we are constantly loading new data in and sliding old data over, eventually to be purged or archived. Before you begin, you must choose either a LEFT partition function window or a RIGHT partition function window:
    1. How
    data is handled varies according to the choice of LEFT or RIGHT partition function window:
    • With a LEFT strategy, partition1 holds the oldest data (Q4 data), partition2 holds data that is 6- to 9-months old (Q3), partition3
    holds data that is 3- to 6-months old (Q2), and partition4 holds recent data less than 3-months old.
    • With a RIGHT strategy, partition4 holds the holds data (Q4), partition3 holds Q3 data, partition2 holds Q2 data, and partition1
    holds recent data.
    • Following the best practice, make sure there are empty partitions on both the leading edge (partition0) and trailing edge (partition5)
    of the partition.
    • RIGHT range functions usually make more sense to most people because it is natural for most people to to start ranges at their lowest
    value and work upward from there.
    2. Assuming
    that a RIGHT partition function windows is used, we first use the SPLIT subclause of the ALTER PARTITION FUNCTIONstatement
    to split empty partition5 into two empty partitions, 5 and 6.
    3. We
    use the SWITCH subclause
    of ALTER TABLE to
    switch out partition4 to a staging table for archiving or simply to drop and purge the data. Partition4 is now empty.
    4. We
    can then use MERGE to
    combine the empty partitions 4 and 5, so that we’re back to the same number of partitions as when we started. This way, partition3 becomes the new partition4, partition2 becomes the new partition3, and partition1 becomes the new partition2.
    5. We
    can use SWITCH to
    push the new quarter’s data into the spot of partition1.
    Tip
    Use the $PARTITION system
    function to determine where a partition function places values within a range of partitions.
    Some best practices to consider for using a slide window partition include the following:
    • Load newest data into a heap, and then add indexes after the load is finished. Delete oldest data or, when working with very large
    data sets, drop the partition with the oldest data.
    • Keep an empty staging partition at the leftmost and rightmost ends of the partition range to ensure that the partitions split when
    loading in new data, and merge, after unloading old data, do not cause data movement.
    • Do not split or merge a partition already populated with data because this can cause severe locking and explosive log growth.
    • Create the load staging table in the same filegroup as the partition you are loading.
    • Create the unload staging table in the same filegroup as the partition you are deleting.
    • Don’t load a partition until its range boundary is met. For example, don’t create and load a partition meant to hold data that is
    one to two months older before the current data has aged one month. Instead, continue to allow the latest partition to accumulate data until the data is ready for a new, full partition.
    • Unload one partition at a time.
    • The ALTER TABLE...SWITCH statement
    issues a schema lock on the entire table. Keep this in mind if regular transactional activity is still going on while a table is being partitioned.
    Thanks Shiven:) If Answer is Helpful, Please Vote

  • Suggestions for table partition for existing tables.

    I have a table as below. This table contains huge data. This table has so many child tables .I am planning to do a 'Reference Partitioning' for the same.
    create table PROMOTION_DTL
      PROMO_ID              NUMBER(10) not null,
      EVENT                 VARCHAR2(6),
      PROMO_START_DATE      TIMESTAMP(6),
      PROMO_END_DATE        TIMESTAMP(6),
      PROMO_COST_START_DATE TIMESTAMP(6),
      EVENT_CUT_OFF_DATE    TIMESTAMP(6),
      REMARKS               VARCHAR2(75),
      CREATE_BY             VARCHAR2(50),
      CREATE_DATE           TIMESTAMP(6),
      UPDATE_BY             VARCHAR2(50),
      UPDATE_DATE           TIMESTAMP(6)
    alter table PROMOTION_DTL
      add constraint PROMOTION_DTL_PK primary key (PROMO_ID);
    alter table PROMOTION_DTL
      add constraint PROMO_EVENT_FK foreign key (EVENT)
      references SP_PROMO_EVENT_MST (EVENT);
    -- Create/Recreate indexes
    create index PROMOTION_IDX1 on PROMOTION_DTL (PROMO_ID, EVENT)
    create unique index PROMOTION_PK on PROMOTION_DTL (PROMO_ID)
    -- Grant/Revoke object privileges
    grant select, insert, update, delete on PROMOTION_DTL to SCHEMA_RW_ROLE;I would like to partition this table .Most of the queries contains the following conditions.
    promo_end_date >=   SYSDATE
    and
    (event = :input_event OR
    (:input_Start_Date <= promo_end_date           
    AND promo_start_date <= :input_End_Date))Any time the promotion can be closed by updating the PROMO_END_DATE.
    Interval partioning on PROMO_END_DATE is not possible as PROMO_END_DATE is a nullable and updatable field.
    I am now to table partition.
    Any suggestions are welcome...

    DO NOT POST THE SAME QUESTION IN MULTIPLE FORUMS PLEASE!
    Suggestions for table partition of existing tables

  • Create table, PARTITION, compress ORACLE SUPPORT PLS !

    Can someone PLEASE explain to me the following (read carefully):
    SQL> create table abc
    2 (a number)
    3 PARTITION BY LIST(a)
    4 (PARTITION A_A values (2),
    5 PARTITION A_B values (DEFAULT) COMPRESS);
    Table created.
    SQL> alter table abc add b number;
    alter table abc add b number
    ERROR at line 1:
    ORA-22856: cannot add columns to object tables
    SQL> alter table abc modify partition A_B nocompress;
    Table altered.
    SQL> alter table abc add b number;
    alter table abc add b number
    ERROR at line 1:
    ORA-22856: cannot add columns to object tables
    SQL> drop table abc;
    Table dropped.
    SQL> create table abc
    2 (a number)
    3 PARTITION BY LIST(a)
    4 (PARTITION A_A values (2),
    5 PARTITION A_B values (DEFAULT));
    Table created.
    SQL> alter table abc modify partition A_B compress;
    Table altered.
    SQL> alter table abc add b number;
    Table altered.
    I definetelly think this is a BUG !

    14464, 00000, "Compression Type not specified"
    // *Cause: Compression Type was not specified in the Compression Clause.
    // *Action: specify Compression Type in the Compression Clause.                                                                                                                                                                                                                                                                                                                                                                                   

  • Doubt on Table Partitions

    hello,
    i am junior dba our company deals with health care products,
    in our project we have a USER REGISTRATION table,in which every user should
    register in that table before joining in the hospital.
    That table contains lakhs of records ,and we made date wise partitions on that table.
    Now my doubt is, all the transactions that are under the particular month will store
    in the appropriate partition.
    for example:
    All the data in the month (MARCH) will store in the (MARCH)partition
    my table contains USERREGISTEREDDATE field default is SYSDATE.
    Now i wan't to change the USERREGISTEREDDATE field which is
    stored in the (MARCH)partition to APRIL ,it is not allowing to change the date,
    because registrations that are done under MARCH are stored in that (MARCH)partition
    can u please give solution to me
    regards
    lakshmi

    Migration of rows to new partitions based on key value changes can be controlled by application of the ENABLE/DISABLE ROW MOVEMENT clause in the CREATE and ALTER TABLE statements.
    ALTER TABLE tableName ENABLE ROW MOVEMENT;
    ~ Madrid.

  • Dynamically create Table partition

    Hi all,
    Anybody having script to add partition to a table using plsql.My requirment is to create partition for every month ( time_id , from time attribute table ) dynamically.
    Thanks in Advance
    Ramesh K C R

    Just build you SQL statement to create partition in a VARCHAR2 variable
    and use EXECUTE IMMEDIATE to run it.
    Take care to have been granted directly privileges to run CREATE TABLE, ALTER TABLE (not through a role) or create you code with AUTHID CURRENT_USER clause.

Maybe you are looking for