Truncating multiple partitions

I am creating a store proc that will truncate selected partitions of a partitioned table. Is there any easy way to do it than the conventional way of looping through cursor and executing multiple alter commands.
alter table <table name> truncate partition p1
alter table <table name> truncate partition p2
alter table <table name> truncate partition p3
and so on..
I am using 10g.

If truncating multiple partitions existed, it could also support updating global indexes clause (supported currently for truncating one partition) - which behaves differently from complete index rebuild and probably suites better for some cases. Just faced with that "want-this-feature" also ).
Combining maintenance operations for multiple partitions in one "multipartition" operation would be useful in some cases. For example partitions merge in one step would generate many times less redo than equivalent partition cycle. Had to implement that "multipartition" merge using insert into another table, truncate original partitions, merge empty partitions, exchange merged partition with this table, which works faster, but is not so reliable as potential "multipartition" operation...

Similar Messages

  • Truncating/droping partitions

    i have to drop around 20 partitions for a particular table .
    the scripts are ready for droping and i have taken a logical export of 20 partitions.
    one thing i have realised is that the table have lot of constarints .
    my first question
    whether constraints need to be dropped/diabled before you can truncate/drop a partition on a partitioned table.
    i have a testing env also
    i ftpd the the logical export file and the truncate scripts to the UAT.
    the UAT env is just a clone of PROD .. so iam trying to import the 20 partitions into the UAT same schema and the same table structure (pls note UAT has got just 5 partitions only)
    while importing i got a new error it says the not null constarint is violated and the unique constarint is violated. i thought there might be a flaw withthe source Db .so i ISSUED SOME QuERIES TO FIND IF THERE ARE null values there and if there are any duplicate records.. the result was no duplicates or null records found.
    so the source is ok
    i turned my eye towards UAT env
    i tried to import the records into the same schema and the same table in UAT.so while doing the import the following was the error
    import: Release 9.2.0.5.0 - Production on Mon Apr 16 11:46:51 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Username: / as sysdba
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.5.0 - Production
    Export file created by EXPORT:V09.02.00 via direct path
    Warning: the objects were exported by ORACLE, not by you
    import done in US7ASCII character set and UTF8 NCHAR character set
    . importing ORACLE's objects into SYS
    . importing NEVADMIN's objects into NEVADMIN
    . . importing partition "BO_NEV_RETENTION":"BO_NEV_RETENTION_M1" 0 rows imported
    . . importing partition "BO_NEV_RETENTION":"BO_NEV_RETENTION_M2"
    IMP-00019: row rejected due to ORACLE error 1
    IMP-00003: ORACLE error 1 encountered
    ORA-00001: unique constraint (NEVADMIN.BO_NEV_RETENTION_PK) violated
    Column : 177943769
    Column : 30-SEP-2002:00:00:00
    Column : 30-SEP-2002:00:00:00
    Column : 1214339
    Column : 10676375
    Column : 28
    Column : 140413
    Column : 140427
    Column : 4533749
    Column : 1176777
    Column : 8
    Column : 61
    Column : 3
    Column : 1631232
    Column : 1
    Column : 12181566
    Column : 211
    Column : 0
    Column : 399000
    Column : 146500
    IMP-00019: row rejected due to ORACLE error 1400
    IMP-00003: ORACLE error 1400 encountered
    ORA-01400: cannot insert NULL into ("NEVADMIN"."BO_NEV_RETENTION"."PARENT_MTG_LOAN_KEY")
    Column :
    Column : ?...
    Column : 30-SEP-2002:00:00:00
    Column : -2.92710000000000E-116
    Column : 1214526
    Column : 10678618
    Column : 26
    Column : 140197
    Column : 140210
    Column : 4409141
    Column : 1176777
    Column : -1
    Column : 61
    Column : 1
    Column : -1
    Column : 1
    Column : 12127061
    Column : 31
    Column : 0
    Column : 389825124.7
    IMP-00009: abnormal end of export file
    Import terminated successfully with warnings
    my second question would be
    is there any flaw with my import.
    this wat i did while i treied to import into the schema
    $imp userid=/ as sysdba commit=y file=/ / /.dmp log=test.log ignore=y full=y buffer=100000
    kindly let me know wat could be the problem!

    If truncating multiple partitions existed, it could also support updating global indexes clause (supported currently for truncating one partition) - which behaves differently from complete index rebuild and probably suites better for some cases. Just faced with that "want-this-feature" also ).
    Combining maintenance operations for multiple partitions in one "multipartition" operation would be useful in some cases. For example partitions merge in one step would generate many times less redo than equivalent partition cycle. Had to implement that "multipartition" merge using insert into another table, truncate original partitions, merge empty partitions, exchange merged partition with this table, which works faster, but is not so reliable as potential "multipartition" operation...

  • Selecting data from Multiple Partitions in a single select stmt.

    Hi all,
    My Database is very large & my tables are partitioned.
    My question is:
    1) If my data is spread across multiple partitions, is there any way to select data from multiple partitions in a single query?
    If we dont mention partition name also it works fine, but perofmance wise it will be very slow. (Using EXPLAIN PLAN)
    (Note:I dont want to make use of Union concept, i want to do it in a single select statement)
    For ex:
    qry1.sql:
    select empno from emp_trans partition (P012000)
    This above query(qry1.sql) will work fine.
    qry2.sql:
    select empno from emp_trans partition (P012000,P022000)
    The above query(qry2.sql) will return will return the following error:
    ORA-00933: SQL command not properly ended
    If anybody has any solution for this, pls mail me immediately.
    Thanks in advance
    bye
    null

    All my queries are dynamically generated. All my tables are also indexed partition wise based on date field. My question is, if i want to mention multiple partition names at the time of generating my query(select), then with parformance will be good. I have refered some books, inthat what they say is to use UNION concept, i dont want to use that, instead i want in a single select statement.
    Thaks for ur reply
    Bye
    null

  • Home Directories when installing on multiple partitions

    I have a macpro setup with two partitions.  Originally one partition assigned to Snow Leopard.  I log in using a network user (using OSX server) and that user has local Admin rights.  All is well.
    I setup a new instance of Snow Leopard on the secondary Partition and logged in using the network user.  This had the effect of using the partition 1 Home directory for this user and I can't get the secondary partition to use itself for storing the users home directory.
    The workaround I have is to log in to Partition 2 snow leopard with a local admin user then temporarily rename the Users folder on partition 1.  Next login to partition 2 as the network user, then everything gets created on partition 2 as expected.  Finally rename the Partition 1 Users folder back.  Now I can log in to either partitoin with the same user and have different local home setups.
    Anyone else had this or is there a better procedure for setting up multiple partitions ?  The same happens with LION.  I need to keep a snowleoapard partition with all the setup I currently have, but start a new LION partition.  I don't want any cross contamination, hence the requirement for separation.

    This was my point. I wanted total separation.  In order to create that separation (when trying to use a network user) I had to temporarily move the existing Snow Leopard Users folder (on Partition 1) so that the Partition 2 OS (either Snow leopard or LION) will create it's own User directory structure.  This is only needed for network users (i.e. ones that authenticate via OSX server).
    Once the process of temporarily moving the Users folder, letting the new instance create it's own directories, and renaming back, everything works.  i.e. when I startup Snowleopard all operations are within Partition 1 then if I start LION all operations are within Partition 2. 
    When installing new versions of an O/S I like to have control and manage the change so that I know I have a totally working system.  Been doing the same with Linux for years, but Mac OS/X tries to be a bit too clever!

  • Is it possible to have multiple partitions on my hard disk drive and use Bootcamp to install Windows?

    Hi all,
    Here is my question: I have MBP early 2011 and was trying to install Windows 8 using Bootcamp but the option to install Windows is grayed out so I can’t click the box next to “Install or Remove Windows 7.” Is this because I have multiple partition on my hard disk drive? Is there anyway I can install Windows 8 using Bootcamp without deleting my partitions on my hard disk?
    Few more details:
    Mountain Lion 10.8.2
    Bootcamp 5.0.0
    Thanks for your response

    You can't create a Boot Camp partition on a drive you've already partitioned, and you can't install Windows 8 through Boot Camp at this time.
    (71680)

  • Warehouse partitioning - performance of queries across multiple partitions?

    Hi,
    We are using Oracle 11.2.0.3 and have a large central fact table with several surrogate ids which have bitmap indexes on them and have fks looking at dimension tables + several measures
    (PRODUCT_ID,
    CUSTOMER_ID,
    DAY_ID,
    TRANS_TYPE_ID,
    REGION_ID,
    QTY
    VALUE)
    We have 2 distinct sets of queries users look to run for most part, ones accessing all transactions for products regradless of the time those transactions happened (i.e. non-financial queries - about 70%,
    queries determining what happened in a particular week - 20% of queries.
    Table will have approx 4bn rows in eventually.
    Considering adding extra column to this DATE and range partition this to allow us to drop old partitions every year - however this data wouldn't be joined to any other table.
    Then considering sub-partitioning by hash of product_id which is surrogate key for product dimension.
    Thoughts on performance?
    Queries by their nature would hit several sub-partitions.
    Thoughts on query performance of queries which access several sub-partitions/partitions versus queries running aganist a single table.
    Any other thoughts on partitioning strategy in our situation much apprecaited.
    Thanks

    >
    Thoughts on query performance of queries which access several sub-partitions/partitions versus queries running aganist a single table.
    >
    Queries that access multiple partitions can improve performance for two use cases: 1) only a subset of the entire table is needed and 2) if the access is done in parallel.
    Even if 9 of 10 partitions are needed that can still be better than scanning a single table containing all of the data. And when there is a logical partitioning key (transaction date) that matches typical query predicate conditions then you can get guaranteed benefits by limiting a query to only 1 (or a small number) partition when an index on a single table might not get used at all.
    Conversely, if all table data is needed (perhaps there is no good partition key) and parallel option is not available then I wouldn't expect any performance benefit for either single table or partitioning.
    You don't mention if you have licensed the parallel option.
    >
    Any other thoughts on partitioning strategy in our situation much apprecaited.
    >
    You provide some confusing information. On the one hand you say that 70% of your queries are
    >
    ones accessing all transactions for products regradless of the time those transactions happened
    >
    But then you add that you are
    >
    Considering adding extra column to this DATE and range partition this to allow us to drop old partitions every year
    >
    How can you drop old partitions every year if 70% of the queries need product data 'regardless of the time those transactions happened'?
    What is the actual 'datetime' requirement'? And what is your definition of 'a particular week'? Does a week cross Month and Year boundaries? Does the requirement include MONTHLY, QUARTERLY or ANNUAL reporting?
    Those 'boundary' requirements (and the online/offline need) are critical inputs to the best partitioning strategy. A MONTHLY partitioning strategy means that for some weeks two partitions are needed. A weekly partitioning strategy means that for some months two partitions are needed. Which queries are run more frequently weekly or monthly?
    Why did you mention sub-partitioning? What benefit do you expect or what problem are you trying to address? And why hash? Hash partitioning guarantees that ALL partitions will be needed for predicate-based queries since Oracle can't prune partitions when it evaluates execution plans.
    The biggest performance benefit of partitioning is when the partition keys used have a high correspondence with the filter predicates used in the queries that you run.
    Contrarily the biggest management benefit of partitioning is when you can use interval partitioning to automate the creation of new partitions (and subpartitions if used) based solely on the data.
    The other big consideration for partitioning, for both performance and management, is the use of global versus local indexes. WIth global indexes (e.g. a global primary key) you can't just drop a partition in isolation; the global primary key needs to be maintained by deleting the corresponding index entries.
    On the other hand if your partition key includes the primary key column(s) then you can use a local index for the primary key. Then partition maintenance (drop, exchange) is very efficient.

  • Problem in truncate/drop partitions in a table having nested table columns.

    Hi,
    I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table? IF I change column types from nested table to varray type, will it help?
    Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
    Thanks in advance.

    >
    I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table?
    >
    Unfortunately you can't do those operations when a table has a nested table column. No truncate, no drop, no exchange partition at the partition level.
    A nested table column is stored as a separate table and acts like a 'child' table with foreign keys to the 'parent' table. It is these 'foreign keys' that prevent the truncation (just like normal foreign keys prevent truncating partions and must be disabled first) but there is no mechanism to 'disable' them.
    Just one excellent example (there are many others) of why you should NOT use object columns at all.
    >
    IF I change column types from nested table to varray type, will it help?
    >
    Yes but I STRONGLY suggest you take this opportunity to change your data model to a standard relational one and put the 'child' (nested table) data into its own table with a foreign key to the parent. You can create a view on the two tables that can make data appear as if you have a nested table type if you want.
    Assuming that you are going to ignore the above advice just create a new VARRAY type and a table with that type as a column. Remember VARRAYs are defined with a maximum size. So the number of nested table records needs to be within the capacity of the VARRAY type for the data to fit.
    >
    Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
    >
    Sure - just CAST the nested table to the VARRAY type. Here is code for a VARRAY type and a new table that shows how to do it.
    -- new array type
    CREATE OR REPLACE TYPE ARRAY_T AS VARRAY(10) OF VARCHAR2(64)
    -- new table using new array type - NOTE there is no nested table storage clause - arrays stored inline
    CREATE TABLE partitioned_table_array
         ( ID_ INT,
          arra_col  ARRAY_T )
         PARTITION BY RANGE (ID_)
         ( PARTITION p1 VALUES LESS THAN (40)
         , PARTITION p2 VALUES LESS THAN(80)
         , PARTITION p3 VALUES LESS THAN(100)
    -- insert the data from the original table converting the nested table data to the varray type
    INSERT INTO PARTITIONED_TABLE_ARRAY
    SELECT ID_, CAST(NESTED_COL AS ARRAY_T) FROM PARTITIONED_TABLENaturally since there is no more nested table storage you can truncate or drop partitions in the above table
    alter table partitioned_table_array truncate partition p1
    alter table partitioned_table_array drop partition p1

  • SSDT SSAS Project: Can't create multiple partitions

    "Warning:  The destination server is running a SQL Server edition that does not support multiple partitions. Please deploy to another server."
    I get this error, when I try to deploy against a SSAS 2012 Developer Edition instance, same happens when I go against a SSAS 2012 Enterprise Edition instance. What part am I missing or is this a SSDT bug ?
    I first posted this question on the SSDT forum since it seems that there are two totally indepentent teams that just work by coinscience under the Microsoft brand on a product that by accicent has the same name "SSDT" ;-) 

    Hi Ernestomawan,
    According to your description, you get this warning when you deploy a SQL Server Analysis Service project to Enterprise Edition instance, right? A you can see on the link
    Features Supported by the Editions of SQL Server 2012(Analysis Services section), Multiple Partitions is supported on
    Enterprise, Business Intelligence and Standard(up to 3) editions.
    So in your scenario, in SQL Server Data Tool go to Project Property Page and ensure that For Deployment Server Edition Enterprise is selected.
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Will there performance improvement over separate tables vs single table with multiple partitions?

    Will there performance improvement over separate tables vs single table with multiple partitions? Is advisable to have separate tables than having a single big table with partitions? Can we expect same performance having single big table with partitions? What is the recommendation approach in HANA?

    Suren,
    first off a friendly reminder: SCN is a public forum and for you as an SAP employee there are multiple internal forums/communities/JAM groups available. You may want to consider this.
    Concerning your question:
    You didn't tell us what you want to do with your table or your set of tables.
    As tables are not only storage units but usually bear semantics - read: if data is stored in one table it means something else than the same data in a different table - partitioned tables cannot simply be substituted by multiple tables.
    Looked at it on a storage technology level, table partitions are practically the same as tables. Each partition has got its own delta store & can be loaded and displaced to/from memory independent from the others.
    Generally speaking there shouldn't be too many performance differences between a partitioned table and multiple tables.
    However, when dealing with partitioned tables, the additional step of determining the partition to work on is always required. If computing the result of the partitioning function takes a major share in your total runtime (which is unlikely) then partitioned tables could have a negative performance impact.
    Having said this: as with all performance related questions, to get a conclusive answer you need to measure the times required for both alternatives.
    - Lars

  • Installing Lion clean on hard drive with multiple partitions

    I have a spring 2008 24" iMac running Snow Leopard.
    I am about to put a new 2TB hard drive in it and after I do that I want to do a clean install of Lion on it.
    I do not want to upgrade my Snow Leopard install to Lion. I will keep it on my back up drive as a fallback incase of serious workflow incompatiblities with the new OS.
    For my workflow I create and use multiple partitions (Mac OS,  Windows and multiple HFS+ for data) on my hard drive and I have seen that Lion creates it's own hidden recovery partition as well for the recovery functionality.
    My questions are:
    1) Will I have issues running Lion on a partition on a hard drive with multiple partitions that have different file systems?
    2) If I install Lion into one of these partitions will it create it's recovery partition within the space of the partition it is being installed into?
    3) I will be creating a clean install by downloading Lion using the App Store and then burning an installer DVD using instructions I found elsewhere and then using that to do the install on the new drive. Is that the best route to take?
    All my current data I will have on a backup external hard drive and after I complete the Lion install on the new larger drive I will manually reinstall all my software and move my data back from my backup drive to the new drive one partition at a time except of course for OS partition. I keep all my real user data outside of that partition anyway.

    I believe this article answers most of your questions.
    http://support.apple.com/kb/HT4718
    or possibly
    http://support.apple.com/kb/HT4649
    You will most likely run into the error message that "Some features of Mac OS X Lion are not supported for the disk" if you have multiple partitions set up, especially if they were not set up using Bootcamp and/or have serveral different file systems.
    You can confirm that the Recovery Partition will not be installed by checking Disk Utility for your current partition map scheme.
    This is most definitely not the end of the world as it is quite easy to create an external Recovery disk.
    1) No, you shouldn't have issues running Lion, but Recovery HD will not be created.
    2) No, and in your case it doesn't sound like it will be installed on your internal drive at all.
    3) Yes. If you begin with an empty partition, then install Lion that would be considered a clean install.
    Hope that helps.
    Autumn

  • How to truncate a partition in owb

    I wonder how can i achieve truncating a partition before loading into this target table. I found this pre-mapping prcess where we have this option of truncating a table, but how can i just truncate a partition within a table in a mapping? please advice.
    ~Prabha

    As per Detlef's suggestion, here's the basics that you can embedd in a function/procedure. Accepts 3 parameters in_table_name, in_subpartition_name and in_partition_name. You can also enhance ALTER statements to REUSE/DROP STORAGE if required.
    v_sql VARCHAR2(250) DEFAULT NULL;
    BEGIN
    IF in_subpartition_name IS NOT NULL THEN
    v_sql := 'ALTER TABLE '||in_table_name||' TRUNCATE SUBPARTITION '||in_subpartition_name;
    ELSIF in_partition_name IS NOT NULL THEN
    v_sql := 'ALTER TABLE '||in_table_name||' TRUNCATE PARTITION '||in_partition_name;
    ELSE
    RAISE no_data_found;
    END IF;
    EXECUTE IMMEDIATE v_sql;

  • How to Create Multiple Partitions in Windows?

    I have just carried out a clean install of Lion then used Boot Camp to install Windows.
    With Snow Leopard I had the ability to create multiple partitions in Windows but this seems impossible in Lion for whatever reason.
    Can anyone please tell me how to achieve this?

    If you're using Boot Camp, I'd post your question on the Boot Camp section:
    http://discussions.apple.com/category.jspa?categoryID=237

  • Time Machine doesn't like external drives with multiple partitions

    I've had a problem with Time Machine on both 10.5.0 & 10.5.1 - Time Machine could not create the initial backup regardless of all the things I tried.
    I have a Powerbook with a 300Gb Maxtor connected via firewire 800. This drive had been partitioned into three partitions (which I've used with other backup tools without problem).
    Apparently the problem I had been having with Time Machine was that there were three separate partitions on the external drive. As soon as I took a chance and wiped all of those partitions and made a single partition, everything was fine.
    I had called Apple Tech Support shortly after I got Leopard and when I discovered the problem with Time Machine. I specifically asked if there would be a problem from the multiple partitions and they didn't think there would be, but they were sure. Looks like Apple was wrong.
    If you are having problems with Time Machine with a drive that has multiple partitions, trying changing your external into a single partition drive.

    You will note that I was referring to a Powerbook and the Apple Partition Scheme. There might be something different happening for Intel/GUID users.
    10.5.1 did address other issues with other partition types. Time Machine seems to have trouble with certain partition schemes. I'm not surprised that multiple partitions and GUID works because of things like bootcamp. Apple probably tested specifically for that type of config. They may not have worked all the bugs out of multiple partitions on a Apple Partition Scheme.

  • Multiple partitions in windows XP

    Is it possible to create multiple partitions in windows XP with boot camp?
    Pls Anyone Help.

    Tuhintt wrote:
    Is it possible to create multiple partitions in windows XP with boot camp?
    Pls Anyone Help.
    What do you mean by "in Windows XP?"
    You need to clarify.
    Do you mean you want to split the XP partition into several smaller partitions, with parts of XP in each one?

  • Multiple Partition in Windows XP.

    Is it possible to create multiple partitions in windows XP?

    Just do a Google search for "partition hard drive windows"
    You'll find many pages with instructions

Maybe you are looking for

  • Standard headphones no longer fitting in iPhone

    Hi, I use the iPod function of my iPhone everyday when I walk to school. Today when I woke up and grabbed my headphones to put them in they would not fit in all the way and the sound that comes out of them is distorted and muted. I tried the pair fro

  • Box around my Flash

    Here's my problem. I have a box appear around my Flash in internet explorer, I know about the lawsuit between Microsoft and Active X, and understand why it is there, and can even get rid of it with a javascipt file. My problem is that whenever I get

  • Cfinput validation is not working

    I have a CF8 cfform which contains several cfinput tags set to required.  If I submit the form without fillign otu those fields, I do get the popup message displaying the error message(s) but when I click ok on that popup, it still submits the form.

  • Vidoes only play the first 10 seco

    When I transfer my .avi videos to my Zen Vision:M it says transfer successful but when I go to play it on my Zen, only the first 6 to 0 seconds play. I don't know why this happens, but when I go to check out the videos first it says "Play time 22:08"

  • I cant signed on the game center on my iphone.which is a japan lock how can i fix this?

    i cant signed on the game center on my iphone.which is a japan lock how can i fix this?