How to cut the large table into pieces

I'm trying to derive some of generic logic that would be cut into pieces of defined size a large table. The goal is to perform the update into pieces and avoid questions too small restoration. The full table on the update scan is inevitable, given that the update target each row of the table.

The BIGTABLE has 63 million lines. The purpose of the bellow SQL to give ID all 2 million rows. So I use the rownum 'auto line numering field' and run a test to see I could. I expected the piece of fist to have 2 million rows, but in fact, it is not the case:

Here is the +(NOTE I had many problems with quotes, so some ROWID appears without their enclosing quotes or they disappear from current output here) code +:
select rn, mod, frow, rownum from (
    select rowid rn ,  rownum frow, mod(rownum, 2000000) mod  
  from bigtable order by rn) where mod = 0
/

SQL> /

RN                        MOD       FROW     ROWNUM
------------------ ---------- ---------- ----------
AAATCjAA0AAAKAVAAd          0    4000000          1
AAATCjAA0AAAPUEAAv          0   10000000          2
AAATCjAA0AAAbULAAx          0    6000000          3
AAATCjAA0AAAsIeAAC          0   14000000          4
AAATCjAA0AAAzhSAAp          0    8000000          5
AAATCjAA0AABOtGAAa          0   26000000          6
AAATCjAA0AABe24AAE          0   16000000          7
AAATCjAA0AABjVgAAQ          0   30000000          8
AAATCjAA0AABn4LAA3          0   32000000          9
AAATCjAA0AAB3pdAAh          0   20000000         10
AAATCjAA0AAB5dmAAT          0   22000000         11
AAATCjAA0AACrFuAAW          0   36000000         12
AAATCjAA6AAAXpOAAq          0    2000000         13
AAATCjAA6AAA8CZAAO          0   18000000         14
AAATCjAA6AABLAYAAj          0   12000000         15
AAATCjAA6AABlwbAAg          0   52000000         16
AAATCjAA6AACBEoAAM          0   38000000         17
AAATCjAA6AACCYGAA1          0   24000000         18
AAATCjAA6AACKfBABI          0   28000000         19
AAATCjAA6AACe0cAAS          0   34000000         20
AAATCjAA6AAFmytAAf          0   62000000         21
AAATCjAA6AAFp+bAA6          0   60000000         22
AAATCjAA6AAF6RAAAQ          0   44000000         23
AAATCjAA6AAHJjDAAV          0   40000000         24
AAATCjAA6AAIR+jAAL          0   42000000         25
AAATCjAA6AAKomNAAE          0   48000000         26
AAATCjAA6AALdcMAA3          0   46000000         27
AAATCjAA9AAACuuAAl          0   50000000         28
AAATCjAA9AABgD6AAD          0   54000000         29
AAATCjAA9AADiA2AAC          0   56000000         30
AAATCjAA9AAEQMPAAT          0   58000000         31

31 rows selected.

SQL> select count(*) from BIGTABLE where rowid < AAATCjAA0AAAKAVAAd ;

  COUNT(*)
----------
    518712             <-- expected around 2 000 000

SQL> select count(*) from BIGTABLE where rowid < AAATCjAA0AAAPUEAAv ;

  COUNT(*)
----------
   1218270     <-- expected around 4 000 000

SQL> select count(*) from BIGTABLE where rowid < AAATCjAA0AAAbULAAx ;

  COUNT(*)
----------
   2685289    <-- expected around 6 000 000
Amzingly, this code works perfectly for small tables, but fails for large tables. Does anyone has an explanation and possibly a solution to this?

Here's the complete SQL code that is suppposed to generate all the predicates, I need to add update statements in order to cut into pieces:
select line  from (
   with v as (select rn, mod, rownum frank from (
       select rowid rn ,  mod(rownum, 2000000) mod
           from BIGTABLE order by rn ) where mod = 0),
      v1 as (
              select rn , frank, lag(rn) over (order by frank) lag_rn  from v ),
      v0 as (
              select count(*) cpt from v)
    select 1, case
                when frank = 1 then ' and rowid  <  ''' ||  rn  || ''''
                when frank = cpt then ' and rowid >= ''' || lag_rn ||''' and rowid < ''' ||rn || ''''
                else ' and rowid >= ''' || lag_rn ||''' and rowid <'''||rn||''''
             end line
from v1, v0
union
select 2, case
           when frank =  cpt then   ' and rowid >= ''' || rn  || ''''
          end line
    from v1, v0 order by 1)
/

 and rowid  <  AAATCjAA0AAAKAVAAd
 and rowid >= 'AAATCjAA0AAAKAVAAd' and rowid < 'AAATCjAA0AAAPUEAAv''
 and rowid >= 'AAATCjAA0AAAPUEAAv' and rowid < 'AAATCjAA0AAAbULAAx''
 and rowid >= 'AAATCjAA0AAAbULAAx' and rowid < 'AAATCjAA0AAAsIeAAC''
 and rowid >= 'AAATCjAA0AAAsIeAAC' and rowid < 'AAATCjAA0AAAzhSAAp''
 and rowid >= 'AAATCjAA0AAAzhSAAp' and rowid < 'AAATCjAA0AABOtGAAa''
 and rowid >= 'AAATCjAA0AAB3pdAAh' and rowid < 'AAATCjAA0AAB5dmAAT''
 and rowid >= 'AAATCjAA0AAB5dmAAT' and rowid < 'AAATCjAA0AACrFuAAW''
 and rowid >= 'AAATCjAA0AABOtGAAa' and rowid < 'AAATCjAA0AABe24AAE''
 and rowid >= 'AAATCjAA0AABe24AAE' and rowid < 'AAATCjAA0AABjVgAAQ''
 and rowid >= 'AAATCjAA0AABjVgAAQ' and rowid < 'AAATCjAA0AABn4LAA3''
 and rowid >= 'AAATCjAA0AABn4LAA3' and rowid < 'AAATCjAA0AAB3pdAAh''
 and rowid >= 'AAATCjAA0AACrFuAAW' and rowid < 'AAATCjAA6AAAXpOAAq''
 and rowid >= 'AAATCjAA6AAA8CZAAO' and rowid < 'AAATCjAA6AABLAYAAj''
 and rowid >= 'AAATCjAA6AAAXpOAAq' and rowid < 'AAATCjAA6AAA8CZAAO''
 and rowid >= 'AAATCjAA6AABLAYAAj' and rowid < 'AAATCjAA6AABlwbAAg''
 and rowid >= 'AAATCjAA6AABlwbAAg' and rowid < 'AAATCjAA6AACBEoAAM''
 and rowid >= 'AAATCjAA6AACBEoAAM' and rowid < 'AAATCjAA6AACCYGAA1''
 and rowid >= 'AAATCjAA6AACCYGAA1' and rowid < 'AAATCjAA6AACKfBABI''
 and rowid >= 'AAATCjAA6AACKfBABI' and rowid < 'AAATCjAA6AACe0cAAS''
 and rowid >= 'AAATCjAA6AACe0cAAS' and rowid < 'AAATCjAA6AAFmytAAf''
 and rowid >= 'AAATCjAA6AAF6RAAAQ' and rowid < 'AAATCjAA6AAHJjDAAV''
 and rowid >= 'AAATCjAA6AAFmytAAf' and rowid < 'AAATCjAA6AAFp+bAA6''
 and rowid >= 'AAATCjAA6AAFp+bAA6' and rowid < 'AAATCjAA6AAF6RAAAQ''
 and rowid >= 'AAATCjAA6AAHJjDAAV' and rowid < 'AAATCjAA6AAIR+jAAL''
 and rowid >= 'AAATCjAA6AAIR+jAAL' and rowid < 'AAATCjAA6AAKomNAAE''
 and rowid >= 'AAATCjAA6AAKomNAAE' and rowid < 'AAATCjAA6AALdcMAA3''
 and rowid >= 'AAATCjAA6AALdcMAA3' and rowid < 'AAATCjAA9AAACuuAAl''
 and rowid >= 'AAATCjAA9AAACuuAAl' and rowid < 'AAATCjAA9AABgD6AAD''
 and rowid >= 'AAATCjAA9AABgD6AAD' and rowid < 'AAATCjAA9AADiA2AAC''
 and rowid >= 'AAATCjAA9AADiA2AAC' and rowid < 'AAATCjAA9AAEQMPAAT''
 and rowid >= 'AAATCjAA9AAEQMPAAT''

33 rows selected.

SQL> select count(*) from BIGTABLE where  1=1 and rowid  <  AAATCjAA0AAAKAVAAd ;

  COUNT(*)
----------
    518712

SQL> select count(*) from BIGTABLE where  1=1 and rowid  >= 'AAATCjAA9AAEQMPAAT'' ;

  COUNT(*)
----------
   1846369
Nice but not accurate...

The problem is that your query implies that ROWID, and ROWNUM are classified in the same way. For small tables it is very often the case, but not for the larger tables. Oracle does not guarantee return records in the order the rowid. However usually it works this way.

You could test ensuring that get you the rownum after you ordered. And see if it works then.

select rn, mod, frow, rownum
from (select rn, rownum frow, mod(rownum, 2000000) mod
        from  (select rowid rn from bigtable order by rn)
        order by rn
        )
where mod = 0
/ 

Tags: Database

Similar Questions

  • How to handle the larger size than the movie disc?

    I couldn't see a razor tool, or something like that in yet that I can use to cut the video if it is larger that the DVD could hold.  What could I do if I am OK to remove some content in order to fit into the drive?

    Thank you!

    How to cut the timeline?  This is the part that I don't understand.

    I don't know that you can. And if you can, I'm not saying that it is a bad idea.

    Drag the end to the beginning. This makes it shorter.

    Drag the beginning to the end; then drag the element remaining in the beginning (do not leave any space empty).

  • How to read the color table in a subvi?

    How to read the color table in a subvi? Is it made by a reference to the table or with a global variable? For a better understanding of the problem, I added to vi. Run the "run.vi." I want to see

    the background color of the table "run.vi" in the subvi called "read color.vi".

    How can I do?

    Thanks in advance

    Norick

    pop up on the wire table refernece and establishes 'control '. Add this control to the icon of the sub - VI decision-making and then wire ref of the appellant to this Terminal VI so the calling VI move the ref to the Subvi.

    Ben

  • How to configure the partition table for SSD?

    Drive: 32 GB SSD

    I accidentally delete without backup partition table information and would like to know how to put the partition table, I can access the tools of partition table, but do not know how to define.

    Does anyone have any suggestions?

    Thanks in advance for your suggestions

    Hello

    Thanks for posting your query in Microsoft Community.

    The SSD could be seen in the disk management window, and you could name and set up as another hard drive internal. To create a partition or volume on a hard disk, you must be logged in as an administrator, and there must be unallocated disk space or free space in an extended hard disk partition. To repartition your hard drive, please consult the following link and check if it helps.

    I can I repartition my hard disk?

    Additional information:

    Create a new Partition on a hard disk in Windows 7

    Hope this information is useful. Let us know if you need more help, we will be happy to help you.

  • How to create the logical tables &amp; how to give joints according to obiee 11g?

    Hello

    I have again to obiee 11g. I want to create the logical tables in MDB layer.

    After that I want to give joins according to MDB.

    I don't know, how to create the logical tables and how to give joints according to obiee 11g?

    Please help me.

    Thanks in advance,

    A.Kavya

    Hello

    The new logical table is right click on the MDB itself, for the join you generally in the business model diagram (again right click on objects).

    Maybe it's better if you start from a kind of tutorial to at least have an overview of what is happening where (layer business and physical layer etc.).

    Take a look at what Oracle has available: Oracle BI EE 11 g

    And no doubt, it can be a good start: https://apexapps.oracle.com/pls/apex/f?p=44785:24:0:NO:P24_CONTENT_ID, P24_PREV_PAGE:9787, 2

  • How to get the underlying tables

    Hi all

    EBS R12.2

    How can I get the underlying tables of the following form?

    Capture.PNG

    Thank you very much

    Jen

    Hello

    Go to help-> review-> properties-> point.

    That's how you get the base table (FND_USER_RESP_GROUPS_INDIRECT):

    Kind regards

    Bashar

  • How to cut the plan of $118.4 (hk) per month?

    How to cut the plan of $118.4 (hk) per month?

    Cancel your membership Adobe Creative Cloud

  • How know what the largest table of my oracle database?

    How know what the largest table of my oracle database?

    SELECT * FROM
    (
    SELECT
    NOM_SEGMENT,
    SEGMENT_TYPE,
    BYTES/1024/1024 MB
    TABLESPACE_NAME
    Of
    DBA_SEGMENTS
    WHERE
    SEGMENT_TYPE = 'TABLE '.
    ORDER BY DESC 3
    )
    WHERE
    ROWNUM<=>

  • How to mark the physical tables as "cacheable"

    Hi all

    Can someone tell me please how to mark the physical tables as "cacheable".

    Thnaks a lot

    You can make cacheable table by clicking twice on the table or go to the properties of the table. You can designate specific time duration for the year, month, days need to keep cacheable. Remember do this on the base tables will affect all alias tables.

    Thank you
    Amol

  • How to recover the deleted table

    Hai

    How to recover the deleted table

    the IMP log = = file tables =

    fromuser =' 'touser =' '
    are you new on s/n? (Sorry for the request this because you asked the steps to import a single table). If you read the docs of oracle, you would have not asked this question

    Kind regards
    Pavan
    http://pavandba.WordPress.com

  • How to insert the legacy data into the QP_RLTD_MODIFIERS table?

    How insert Legacy data into the QP_RLTD_MODIFIERS table in the instance of R12.

    I would use the QP_Modifiers_PUB API. Process_Modifiers to push the old data on prices in R12.  QP_RLTD_MODIFIERS is only used for certain types of discounts (in my prod environment, only the promos are given in this table).

  • Can some one please help me to the cutting of the large table Partition

    I wanted to run a query on a particular user say: FRDZ, but I shot by mistake against the SYS user in the same database.

    I know the table, the parition, the tablespace everything belongs to the user FRDZ. Yet the resulting table changed under the SYS user.

    Was it important to connect with this user and then fire the same query for results or it would automatically lead to the same result. Please guide.

    ALTER TABLE SPLIT PARTITION VALUES clnt_default cash_app_sum (3820)
    INTO (PARTITION clnt_3820 TABLESPACE qips_dat_lrg02,
    PARTITION clnt_default TABLESPACE qips_dat_lrg02);

    I tried to connect to the real user (FRDZ) later and pulled the same query that it it shows 3820 does not exist.

    Published by: 784786 on June 1st, 2011 05:53

    Published by: 784786 on June 1, 2011 06:15

    You have divided the partition.

    Hemant K Collette

  • How to cut the great movie for download on YouTube

    In my Finder, in all the films, there is a video, I want to send on YouTube.  However, the original is very big at 1.64 GB (or at least that's what says "Get Info" in the Finder).  I already tried to divide the movie into 4 parts using the Trim function, but even in this case, each segment is between 300 and 420 MB each!

    Is there an easy way to divide the film into several parts, each of them being the maximum size accepted by YouTube?  I could call and then with part # s for download on YouTube. Not sure, but I think that YouTube has a max of 25 MB per upload to film?  So I guess I'll end up with way too many pieces, LOL.

    I could erase parts of the film strip, but I'm not familiar with the process and have "cut" never the movie of "front-end" or the "back-end" (well Yes, I said, I'm not an expert).   Bottom line: I want to get the movie in its entirety on YouTube somehow.

    All advice welcome.  The film is already 4 years old and I did not understand this in order to share with the family.

    R

    https://search.Yahoo.com/search?p=compressing%20video%20Files%20mac

    How about do your own research online for the You Tube tutorials for how to use the iMovie version you have on your OS X 10.6.8 iMac and how to edit clips make movies shorter and weaker in the size of the file.

    The discussions and the answers you need are too detailed tedious to cover in a forum for troubleshooting.

    A lot of YouTube videos for you help with your film questions of edition.

    You just need to look for the tutorial iMovie, you need.

    You had 4 years to do your own research on how to change your own created movies.

    YouTube has a lot of video tutorials to help you with this, and you can play these video the long while real using iMovie to make the tutorial!

    Good luck to you.

  • How to cut the upper and lower parts in PrE8?

    Hey!

    What is the best way to 'cut' capital letters and tiny pieces of the video screen and finalization that like a movie? I try to get a large "cinematic" with this look, but I'm not sure how well do things. I found, and that by adding adjustable black 'streaks' to the upper and lower part of the screen, but y at - it a way to film the last hand count only the pixels that really show us the picture?

    If I use the effect, the film is always rendered at 1280 x 720 pixels, but I try to avoid making these 'blackened' top and bottom pixels on the screen.

    Okay, I'm not sure if I make my self clear with this crappy description but I hope you understand. ;-)

    Thank you

    -Mike

    Are you trying to turn a 4:3 video to 16:9?

    There is a way to fake - although it is upscaling, if your video is not clear.

    To do this:

    (1) export your video filled with your current project to share/Personal Computer / AVI.

    (2) open a new project. Go in your project settings and change them to widescreen.

    (3) get media/PC files and folders to add the AVI file your created in step 1 to your project, and then add the item to your timeline.

    (4) make a right click on your clip on the timeline, and then select view properties to open the properties panel.

    (5) open the query property in the properties panel and set the scale to 133%.

    Voila!

  • How to cut the column data

    Gurus in the morning

    I have two tables with the data in the corresponding column, BUT I need to cut the columns in a table
    the data is displayed as follows in table xpq_log
    LOG_DATE                     LOG_PTR     LOG_HDR
    01/06/2011 00:00:00     0609pro     0609IN002C_06
    04/06/2011 00:00:00     0609pro     0609IN002C_06
    05/06/2011 00:00:00     0609pro     0609IN002C_06
    06/06/2011 00:00:00     0609pro     0609IN002C_06
    07/06/2011 00:00:00     0609pro     0609IN002C_06
    09/06/2011 00:00:00     0609pro     0609IN002C_06
    10/06/2011 00:00:00     0609pro     0609IN002C_06
    12/06/2011 00:00:00     0609pro     0609IN002C_06
    01/06/2012 00:00:00     0609pro     0609IN002C_06
    02/06/2012 00:00:00     0609pro     0609IN002C_06
    03/06/2012 00:00:00     0609pro     0609IN002C_06
    06/06/2012 00:00:00     0609pro     0609IN002C_06
    07/06/2012 00:00:00     0609pro     0609IN002C_06
    08/06/2012 00:00:00     0609pro     0609IN002C_06
    09/06/2012 00:00:00     0609pro     0609IN002C_06
    In the table of printpdf as follows
    PDF_REPORT     PDF_DESCRIPTION
    IN002C                     STOCK FILE PURGE - PRINT WH CONTROL
    How can I cut the column data (log_hdr) to match column (pdf_report)?

    Any help will be much appreciated

    user11978142 wrote:
    Yes the code always starts with an alphabetic character and always ends before the underscore character and the prefix is always digital.

    And Yes to the second comment WRT 1 to many relationship.

    WRT the duplicates I want the info displayed even if there is no matching printpdf

    You talk a LEFT OUTER JOIN, then:

    See the example below (the statement are just to reproduce the paintings, just use the last query):

    WITH xpq_log AS
    (
       SELECT '0499SYS003A_06' log_hdr FROM DUAL UNION ALL
       SELECT '0612PV410W1_06' log_hdr FROM DUAL UNION ALL
       SELECT '0609IN002C_06' log_hdr FROM DUAL UNION ALL
       SELECT '2201PA100D1_30' log_hdr FROM DUAL
    )
    , printpdf AS
    (
       SELECT 'SYS003A' pdf_report, 'STOCK FILE PURGE - PRINT WH CONTROL' description FROM DUAL UNION ALL
       SELECT 'PV410W1' pdf_report, 'Description 2' description FROM DUAL
    )
    SELECT a.log_hdr, REGEXP_SUBSTR (a.log_hdr, '[[:alpha:]][^_]*') AS pdf_report
         , b.description
      FROM xpq_log a LEFT OUTER JOIN printpdf b
           ON pdf_report = REGEXP_SUBSTR (a.log_hdr, '[[:alpha:]][^_]*');
    
    Output:
    LOG_HDR        PDF_REPORT     DESCRIPTION
    -------------- -------------- -----------------------------------
    0499SYS003A_06 SYS003A        STOCK FILE PURGE - PRINT WH CONTROL
    0612PV410W1_06 PV410W1        Description 2
    2201PA100D1_30 PA100D1
    0609IN002C_06  IN002C                                           
    

    Kind regards.
    Al

Maybe you are looking for

  • Cannot add shockwave plugin to the new copy of Firefox 38.0.5

    Have installed a new copy of firefox 38.0.5 to replace a beta on a surface of 3 pro with win 8.1. When I look at the plugins, Shockware Flash 17.0.0.188 is not there. When I look at the list of plugins available, Shockwave Flash is not there either.

  • My printer is suddenly feel so small, I see little

    All I feel that isn't the Internet or email is fine. All documents saved etc. will print as they always have. But all of a sudden anything from the Internet or emails that I print are so small, I can hardly read them.

  • The HT820 ear and lower volume stuck button

    I had these headphones for almost 2 years works very well. I don't have a bluetooth phone, but I use my HT820 with my HP Ipaq 211 listening to music or watching movies. I also connected them to my work and the home pc. At work I connected them to the

  • What are all the red marked area?

    I want to know on my mobile. Can someone tell me about the red zone indicated on the attached photo? I hope its sensors. but I need to know what sensors are those.

  • KB951978 failed Invalid scrrun.dll

    Update for Windows XP (KB951978) Install this update to resolve the problem in scripts VBScript/JScript from CScript\WScript hosts, certain built-ins may not work correctly when Standards and Formats in the locale is changed.  After you install this