Determine space used by table partitions

Hello,
I deal with a table that is made up of about 30 partitions. How can I determin (query) how much GB or TB those
partitions actually use on the hard disk?
Thanks

You can use
SELECT SEGMENT_NAME TABLE_NAME, PARTITION_NAME,
SEGMENT_TYPE,
SUM(BYTES)/(1024*1024) table_size_meg
FROM dba_segments
WHERE segment_type = 'TABLE PARTITION'
AND owner = 'ownername'
AND segment_name = 'table name'
GROUP BY partition_name;Regards
Renjith Madhavan

Similar Messages

  • Space Allocated and Space used for Table.

    Hi,
    Is there any way, we can find Space Allocated and Space used for Table wise.
    I know USER_TABLESPACES help use to find table space wise. But I would like to know, the space utilized by each table in the specific table space.

    Check this link from Tom Kyte about it.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:2092735390859556::::P11_QUESTION_ID:231414051079

  • Used Space is much higher than actual space used in the partition

    Hi All,
    I am facing space problem in oracle Linux 5.3.
    The parition /oradata is showing Used space as 379 GB when checked with df -TH command and when i go to partition and check space with du -sh command it is showing 280 GB.
    How could i reclaim the space.
    [orah@hih oracle]$ df -TH
    Filesystem Type Size Used Avail Use% Mounted on
    /dev/sda3 ext3 16G 1.0G 14G 7% /
    /dev/sda4 ext3 11G 2.9G 6.8G 31% /usr
    /dev/sdb5 ext3 11G 158M 9.5G 2% /tmp
    /dev/sdb3 ext3 51G 189M 48G 1% /orasig
    /dev/sdb2 ext3 11G 277M 9.4G 3% /var
    /dev/sdb1 ext3 71G 12G 56G 17% /oracle
    /dev/sda1 ext3 104M 16M 83M 17% /boot
    tmpfs tmpfs 26G 9.6M 26G 1% /dev/shm
    /dev/sdc ext3 529G 379G 140G 74% /oradata
    /dev/sdd ext3 529G 401G 128G 76% /orabkp
    /dev/sde ext3 212G 197G 14G 94% /oraprod1
    /dev/sdf ext3 119G 73G 45G 63% /stage
    Rgds,
    Alig

    What is your output of df -h?
    -H uses powers of 1000, not 1024. Computer memory uses binary logic based on the power of 2 (2^10 = 1024, 8 * 8 * 8 * 2 = 1024)
    Anyway, df and du measure different things:
    "du" reports the space used by files and folders
    "df" reports the space used by the file system, which includes the overhead for journals and inode tables.
    If a file is open by a user and the same file is deleted then df and du will report different output.
    A reboot of the system should align df and du output more closely.

  • How Find space Used by Tables and Indexes

    Dear All(s)
    How i check space used (and number of rows) by each table and index in schema. ( can i check current space utilization and sysdate-date past in time)
    How i can check used, and free space for each database and tablespace.
    Thanks

    You can always use the search feature
    anyway
    how to calculate the percentage of free space for a table in Oracle
    Re: incorrect free space in dba_free_space
    These links could give you all the necessary info

  • How can we use the table partitions feature and.........

    Hai friends when i tried to use the bitmap indexes and table partitions feature ,
    I got a message like this
    'table partiotion feature not enabled'
    so please tell me how can i enable those features so that i will be able to use those features..........

    Partitioning and Bitmap Indexes are features of Oracle Enterprise addition. In fact, I think that Partitioning is an extra option that needs to purchased with Oracle Enterprise - it is not a default feature.
    These features do not exist on Oracle Standard Edition (and likely Express Edition too).

  • Quick question on how CBO determines hows to access table partitions

    Hey all,
    I have a large table that is range partitioned on a "code" within the table (about 23 unique values). I'm able to query it very quickly and easily when I specify the code in a query... ie:
    select *
    from large_table
    where code = 'X'
    However, I am looking to calculate the code based on a reference table that I have. I can easily re-create the performance drop doing:
    select *
    from large_table
    where code = (Select 'X' from dual)
    When running the 2nd SQL, my query takes a very long time. I think I understand why (CBO can't "guess" the results of the subquery) and I understand that the easiest to fix this would be to just run the subquery first and pass its results to a second query.
    My question is if anyone knows of a way to provide the CBO a hint or any other trick that would allow Oracle to scan a single partition instead of the whole table using a method like this?

    Thanks Tubby, that link at least helps confirm my original reasoning for the degraded performance and appears to be for similar reasons
    As for the explain plans, here they are:
    (Slow Query -- Object names have been changed)
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop | TQ |IN-OUT| PQ Distrib |
    | 0 | SELECT STATEMENT | | 413 | 219K| | 18794 (1)| 00:03:46 | | | | | |
    | 1 | PX COORDINATOR | | | | | | | | | | | |
    | 2 | PX SEND QC (RANDOM) | :TQ10013 | 413 | 219K| | 18794 (1)| 00:03:46 | | | Q1,13 | P->S | QC (RAND) |
    |* 3 | HASH JOIN RIGHT SEMI BUFFERED | | 413 | 219K| | 18794 (1)| 00:03:46 | | | Q1,13 | PCWP | |
    | 4 | BUFFER SORT | | | | | | | | | Q1,13 | PCWC | |
    | 5 | PX RECEIVE | | 2 | 8 | | 15 (7)| 00:00:01 | | | Q1,13 | PCWP | |
    | 6 | PX SEND HASH | :TQ10003 | 2 | 8 | | 15 (7)| 00:00:01 | | | | S->P | HASH |
    | 7 | VIEW | VW_NSO_1 | 2 | 8 | | 15 (7)| 00:00:01 | | | | | |
    | 8 | VIEW | view_ref_table | 2 | 26 | | 15 (7)| 00:00:01 | | | | | |
    |* 9 | TABLE ACCESS FULL | ref_table | 2 | 22 | | 15 (7)| 00:00:01 | | | | | |
    | 10 | PX RECEIVE | | 4543 | 2391K| | 18779 (1)| 00:03:46 | | | Q1,13 | PCWP | |
    | 11 | PX SEND HASH | :TQ10012 | 4543 | 2391K| | 18779 (1)| 00:03:46 | | | Q1,12 | P->P | HASH |
    |* 12 | HASH JOIN | | 4543 | 2391K| | 18779 (1)| 00:03:46 | | | Q1,12 | PCWP | |
    | 13 | BUFFER SORT | | | | | | | | | Q1,12 | PCWC | |
    | 14 | PX RECEIVE | | 11 | 187 | | 5 (0)| 00:00:01 | | | Q1,12 | PCWP | |
    | 15 | PX SEND BROADCAST | :TQ10002 | 11 | 187 | | 5 (0)| 00:00:01 | | | | S->P | BROADCAST |
    |* 16 | TABLE ACCESS FULL | threshold_table | 11 | 187 | | 5 (0)| 00:00:01 | | | | | |
    |* 17 | VIEW | | 430K| 214M| | 18774 (1)| 00:03:46 | | | Q1,12 | PCWP | |
    | 18 | WINDOW SORT | | 430K| 130M| 280M| 18774 (1)| 00:03:46 | | | Q1,12 | PCWP | |
    | 19 | PX RECEIVE | | 430K| 130M| | 18772 (1)| 00:03:46 | | | Q1,12 | PCWP | |
    | 20 | PX SEND HASH | :TQ10011 | 430K| 130M| | 18772 (1)| 00:03:46 | | | Q1,11 | P->P | HASH |
    |* 21 | HASH JOIN BUFFERED | | 430K| 130M| | 18772 (1)| 00:03:46 | | | Q1,11 | PCWP | |
    | 22 | BUFFER SORT | | | | | | | | | Q1,11 | PCWC | |
    | 23 | PX RECEIVE | | 7332 | 157K| | 16 (13)| 00:00:01 | | | Q1,11 | PCWP | |
    | 24 | PX SEND HASH | :TQ10001 | 7332 | 157K| | 16 (13)| 00:00:01 | | | | S->P | HASH |
    | 25 | VIEW | view_ref_table | 7332 | 157K| | 16 (13)| 00:00:01 | | | | | |
    | 26 | WINDOW SORT | | 7332 | 80652 | | 16 (13)| 00:00:01 | | | | | |
    | 27 | TABLE ACCESS FULL | ref_table | 7332 | 80652 | | 14 (0)| 00:00:01 | | | | | |
    | 28 | PX RECEIVE | | 129K| 36M| | 18756 (1)| 00:03:46 | | | Q1,11 | PCWP | |
    | 29 | PX SEND HASH | :TQ10010 | 129K| 36M| | 18756 (1)| 00:03:46 | | | Q1,10 | P->P | HASH |
    | 30 | BUFFER SORT | | 413 | 219K| | | | | | Q1,10 | PCWP | |
    | 31 | NESTED LOOPS | | 129K| 36M| | 18756 (1)| 00:03:46 | | | Q1,10 | PCWP | |
    | 32 | NESTED LOOPS | | 124K| 30M| | 14444 (1)| 00:02:54 | | | Q1,10 | PCWP | |
    | 33 | NESTED LOOPS | | 122K| 25M| | 10173 (1)| 00:02:03 | | | Q1,10 | PCWP | |
    |* 34 | HASH JOIN | | 123K| 23M| | 5893 (1)| 00:01:11 | | | Q1,10 | PCWP | |
    | 35 | PX RECEIVE | | 124K| 22M| | 5629 (1)| 00:01:08 | | | Q1,10 | PCWP | |
    | 36 | PX SEND HASH | :TQ10008 | 124K| 22M| | 5629 (1)| 00:01:08 | | | Q1,08 | P->P | HASH |
    | 37 | BUFFER SORT | | 413 | 219K| | | | | | Q1,08 | PCWP | |
    | 38 | NESTED LOOPS | | 124K| 22M| | 5629 (1)| 00:01:08 | | | Q1,08 | PCWP | |
    |* 39 | HASH JOIN | | 122K| 20M| | 1797 (2)| 00:00:22 | | | Q1,08 | PCWP | |
    | 40 | PX RECEIVE | | 119K| 17M| | 1101 (3)| 00:00:14 | | | Q1,08 | PCWP | |
    | 41 | PX SEND HASH | :TQ10006 | 119K| 17M| | 1101 (3)| 00:00:14 | | | Q1,06 | P->P | HASH |
    |* 42 | HASH JOIN | | 119K| 17M| | 1101 (3)| 00:00:14 | | | Q1,06 | PCWP | |
    | 43 | BUFFER SORT | | | | | | | | | Q1,06 | PCWC | |
    | 44 | PX RECEIVE | | 86 | 602 | | 3 (0)| 00:00:01 | | | Q1,06 | PCWP | |
    | 45 | PX SEND BROADCAST | :TQ10000 | 86 | 602 | | 3 (0)| 00:00:01 | | | | S->P | BROADCAST |
    | 46 | TABLE ACCESS FULL | OFFICE | 86 | 602 | | 3 (0)| 00:00:01 | | | | | |
    |* 47 | HASH JOIN | | 119K| 16M| | 1098 (3)| 00:00:14 | | | Q1,06 | PCWP | |
    | 48 | PX RECEIVE | | 47 | 940 | | 2 (0)| 00:00:01 | | | Q1,06 | PCWP | |
    | 49 | PX SEND BROADCAST | :TQ10004 | 47 | 940 | | 2 (0)| 00:00:01 | | | Q1,04 | P->P | BROADCAST |
    | 50 | PX BLOCK ITERATOR | | 47 | 940 | | 2 (0)| 00:00:01 | | | Q1,04 | PCWC | |
    |* 51 | TABLE ACCESS FULL | REF | 47 | 940 | | 2 (0)| 00:00:01 | | | Q1,04 | PCWP | |
    |* 52 | HASH JOIN | | 701K| 84M| | 1095 (3)| 00:00:14 | | | Q1,06 | PCWP | |
    | 53 | PX RECEIVE | | 12 | 240 | | 2 (0)| 00:00:01 | | | Q1,06 | PCWP | |
    | 54 | PX SEND BROADCAST | :TQ10005 | 12 | 240 | | 2 (0)| 00:00:01 | | | Q1,05 | P->P | BROADCAST |
    | 55 | PX BLOCK ITERATOR | | 12 | 240 | | 2 (0)| 00:00:01 | | | Q1,05 | PCWC | |
    |* 56 | TABLE ACCESS FULL | REF | 12 | 240 | | 2 (0)| 00:00:01 | | | Q1,05 | PCWP | |
    | 57 | PX BLOCK ITERATOR | | 16M| 1617M| | 1090 (2)| 00:00:14 | 1 | 24 | Q1,06 | PCWC | |
    | 58 | TABLE ACCESS FULL | Fact_Table | 16M| 1617M| | 1090 (2)| 00:00:14 | 1 | 24 | Q1,06 | PCWP | |
    | 59 | PX RECEIVE | | 13M| 323M| | 693 (1)| 00:00:09 | | | Q1,08 | PCWP | |
    | 60 | PX SEND HASH | :TQ10007 | 13M| 323M| | 693 (1)| 00:00:09 | | | Q1,07 | P->P | HASH |
    | 61 | PX BLOCK ITERATOR | | 13M| 323M| | 693 (1)| 00:00:09 | | | Q1,07 | PCWC | |
    | 62 | TABLE ACCESS FULL | Dimension 1 | 13M| 323M| | 693 (1)| 00:00:09 | | | Q1,07 | PCWP | |
    | 63 | TABLE ACCESS BY INDEX ROWID | Dimesnion 2 | 1 | 12 | | 0 (0)| 00:00:01 | | | Q1,08 | PCWP | |
    |* 64 | INDEX UNIQUE SCAN | Dimension 2 Index | 1 | | | 0 (0)| 00:00:01 | | | Q1,08 | PCWP | |
    | 65 | PX RECEIVE | | 15M| 151M| | 261 (2)| 00:00:04 | | | Q1,10 | PCWP | |
    | 66 | PX SEND HASH | :TQ10009 | 15M| 151M| | 261 (2)| 00:00:04 | | | Q1,09 | P->P | HASH |
    | 67 | PX BLOCK ITERATOR | | 15M| 151M| | 261 (2)| 00:00:04 | | | Q1,09 | PCWC | |
    | 68 | INDEX FAST FULL SCAN | Dimension 1 Index | 15M| 151M| | 261 (2)| 00:00:04 | | | Q1,09 | PCWP | |
    | 69 | TABLE ACCESS BY INDEX ROWID | Dimension 3 | 1 | 18 | | 0 (0)| 00:00:01 | | | Q1,10 | PCWP | |
    |* 70 | INDEX UNIQUE SCAN | Dimension 3 Index | 1 | | | 0 (0)| 00:00:01 | | | Q1,10 | PCWP | |
    | 71 | PARTITION HASH ITERATOR | | 1 | 39 | | 0 (0)| 00:00:01 | KEY | KEY | Q1,10 | PCWP | |
    | 72 | TABLE ACCESS BY LOCAL INDEX ROWID| Dimension 4 | 1 | 39 | | 0 (0)| 00:00:01 | KEY | KEY | Q1,10 | PCWP | |
    |* 73 | INDEX UNIQUE SCAN | dimension 6 Index | 1 | | | 0 (0)| 00:00:01 | KEY | KEY | Q1,10 | PCWP | |
    | 74 | TABLE ACCESS BY INDEX ROWID | Dimension 5 | 1 | 38 | | 0 (0)| 00:00:01 | | | Q1,10 | PCWP | |
    |* 75 | INDEX UNIQUE SCAN | Dimension 5 index | 1 | | | 0 (0)| 00:00:01 | | | Q1,10 | PCWP | |
    (Fast Query -- Object Names Changed)
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop | TQ |IN-OUT| PQ Distrib |
    | 0 | SELECT STATEMENT | | 107 | 57673 | | 1302 (1)| 00:00:16 | | | | | |
    | 1 | PX COORDINATOR | | | | | | | | | | | |
    | 2 | PX SEND QC (RANDOM) | :TQ10009 | 107 | 57673 | | 1302 (1)| 00:00:16 | | | Q1,09 | P->S | QC (RAND) |
    |* 3 | HASH JOIN BUFFERED | | 107 | 57673 | | 1302 (1)| 00:00:16 | | | Q1,09 | PCWP | |
    | 4 | BUFFER SORT | | | | | | | | | Q1,09 | PCWC | |
    | 5 | PX RECEIVE | | 11 | 187 | | 5 (0)| 00:00:01 | | | Q1,09 | PCWP | |
    | 6 | PX SEND HASH | :TQ10002 | 11 | 187 | | 5 (0)| 00:00:01 | | | | S->P | HASH |
    |* 7 | TABLE ACCESS FULL | Threshold Table | 11 | 187 | | 5 (0)| 00:00:01 | | | | | |
    | 8 | PX RECEIVE | | 10163 | 5180K| | 1296 (1)| 00:00:16 | | | Q1,09 | PCWP | |
    | 9 | PX SEND HASH | :TQ10008 | 10163 | 5180K| | 1296 (1)| 00:00:16 | | | Q1,08 | P->P | HASH |
    |* 10 | VIEW | | 10163 | 5180K| | 1296 (1)| 00:00:16 | | | Q1,08 | PCWP | |
    | 11 | WINDOW SORT | | 10163 | 3185K| 6792K| 1296 (1)| 00:00:16 | | | Q1,08 | PCWP | |
    | 12 | PX RECEIVE | | 10163 | 3185K| | 1295 (1)| 00:00:16 | | | Q1,08 | PCWP | |
    | 13 | PX SEND HASH | :TQ10007 | 10163 | 3185K| | 1295 (1)| 00:00:16 | | | Q1,07 | P->P | HASH |
    |* 14 | HASH JOIN BUFFERED | | 10163 | 3185K| | 1295 (1)| 00:00:16 | | | Q1,07 | PCWP | |
    | 15 | BUFFER SORT | | | | | | | | | Q1,07 | PCWC | |
    | 16 | PX RECEIVE | | 148 | 3256 | | 15 (7)| 00:00:01 | | | Q1,07 | PCWP | |
    | 17 | PX SEND HASH | :TQ10001 | 148 | 3256 | | 15 (7)| 00:00:01 | | | | S->P | HASH |
    | 18 | VIEW | view_ref table | 148 | 3256 | | 15 (7)| 00:00:01 | | | | | |
    | 19 | WINDOW SORT | | 148 | 2072 | | 15 (7)| 00:00:01 | | | | | |
    |* 20 | TABLE ACCESS FULL | ref table | 148 | 2072 | | 14 (0)| 00:00:01 | | | | | |
    | 21 | PX RECEIVE | | 6867 | 2005K| | 1279 (1)| 00:00:16 | | | Q1,07 | PCWP | |
    | 22 | PX SEND HASH | :TQ10006 | 6867 | 2005K| | 1279 (1)| 00:00:16 | | | Q1,06 | P->P | HASH |
    | 23 | BUFFER SORT | | 107 | 57673 | | | | | | Q1,06 | PCWP | |
    | 24 | NESTED LOOPS | | 6867 | 2005K| | 1279 (1)| 00:00:16 | | | Q1,06 | PCWP | |
    | 25 | NESTED LOOPS | | 6591 | 1679K| | 1050 (1)| 00:00:13 | | | Q1,06 | PCWP | |
    |* 26 | HASH JOIN | | 6604 | 1567K| | 821 (1)| 00:00:10 | | | Q1,06 | PCWP | |
    | 27 | BUFFER SORT | | | | | | | | | Q1,06 | PCWC | |
    | 28 | PX RECEIVE | | 86 | 602 | | 3 (0)| 00:00:01 | | | Q1,06 | PCWP | |
    | 29 | PX SEND HASH | :TQ10000 | 86 | 602 | | 3 (0)| 00:00:01 | | | | S->P | HASH |
    | 30 | TABLE ACCESS FULL | OFFICE | 86 | 602 | | 3 (0)| 00:00:01 | | | | | |
    | 31 | PX RECEIVE | | 6604 | 1522K| | 817 (1)| 00:00:10 | | | Q1,06 | PCWP | |
    | 32 | PX SEND HASH | :TQ10005 | 6604 | 1522K| | 817 (1)| 00:00:10 | | | Q1,05 | P->P | HASH |
    | 33 | NESTED LOOPS | | 6604 | 1522K| | 817 (1)| 00:00:10 | | | Q1,05 | PCWP | |
    | 34 | NESTED LOOPS | | 6541 | 1258K| | 590 (1)| 00:00:08 | | | Q1,05 | PCWP | |
    | 35 | NESTED LOOPS | | 6612 | 1207K| | 475 (1)| 00:00:06 | | | Q1,05 | PCWP | |
    | 36 | NESTED LOOPS | | 6507 | 1112K| | 272 (2)| 00:00:04 | | | Q1,05 | PCWP | |
    |* 37 | HASH JOIN | | 6352 | 924K| | 51 (4)| 00:00:01 | | | Q1,05 | PCWP | |
    | 38 | PX RECEIVE | | 47 | 940 | | 2 (0)| 00:00:01 | | | Q1,05 | PCWP | |
    | 39 | PX SEND BROADCAST | :TQ10003 | 47 | 940 | | 2 (0)| 00:00:01 | | | Q1,03 | P->P | BROADCAST |
    | 40 | PX BLOCK ITERATOR | | 47 | 940 | | 2 (0)| 00:00:01 | | | Q1,03 | PCWC | |
    |* 41 | TABLE ACCESS FULL | REF | 47 | 940 | | 2 (0)| 00:00:01 | | | Q1,03 | PCWP | |
    |* 42 | HASH JOIN | | 37236 | 4690K| | 48 (3)| 00:00:01 | | | Q1,05 | PCWP | |
    | 43 | PX RECEIVE | | 12 | 240 | | 2 (0)| 00:00:01 | | | Q1,05 | PCWP | |
    | 44 | PX SEND BROADCAST | :TQ10004 | 12 | 240 | | 2 (0)| 00:00:01 | | | Q1,04 | P->P | BROADCAST |
    | 45 | PX BLOCK ITERATOR | | 12 | 240 | | 2 (0)| 00:00:01 | | | Q1,04 | PCWC | |
    |* 46 | TABLE ACCESS FULL | REF | 12 | 240 | | 2 (0)| 00:00:01 | | | Q1,04 | PCWP | |
    | 47 | PX BLOCK ITERATOR | | 849K| 88M| | 46 (3)| 00:00:01 | KEY | KEY | Q1,05 | PCWC | |
    | 48 | TABLE ACCESS FULL | Fact Table | 849K| 88M| | 46 (3)| 00:00:01 | 5 | 5 | Q1,05 | PCWP | |
    | 49 | TABLE ACCESS BY INDEX ROWID | Dim 1     | 1 | 26 | | 0 (0)| 00:00:01 | | | Q1,05 | PCWP | |
    |* 50 | INDEX UNIQUE SCAN | Dim 1 index | 1 | | | 0 (0)| 00:00:01 | | | Q1,05 | PCWP | |
    | 51 | TABLE ACCESS BY INDEX ROWID | Dim 2 | 1 | 12 | | 0 (0)| 00:00:01 | | | Q1,05 | PCWP | |
    |* 52 | INDEX UNIQUE SCAN | Dim 2 index | 1 | | | 0 (0)| 00:00:01 | | | Q1,05 | PCWP | |
    |* 53 | INDEX UNIQUE SCAN | Dim 3 Index | 1 | 10 | | 0 (0)| 00:00:01 | | | Q1,05 | PCWP | |
    | 54 | PARTITION HASH ITERATOR | | 1 | 39 | | 0 (0)| 00:00:01 | KEY | KEY | Q1,05 | PCWP | |
    | 55 | TABLE ACCESS BY LOCAL INDEX ROWID| Dim 4 | 1 | 39 | | 0 (0)| 00:00:01 | KEY | KEY | Q1,05 | PCWP | |
    |* 56 | INDEX UNIQUE SCAN | Dim 4 Index | 1 | | | 0 (0)| 00:00:01 | KEY | KEY | Q1,05 | PCWP | |
    | 57 | TABLE ACCESS BY INDEX ROWID | Dim 5 | 1 | 18 | | 0 (0)| 00:00:01 | | | Q1,06 | PCWP | |
    |* 58 | INDEX UNIQUE SCAN | Dim 5 Index | 1 | | | 0 (0)| 00:00:01 | | | Q1,06 | PCWP | |
    | 59 | TABLE ACCESS BY INDEX ROWID | Dim 6 | 1 | 38 | | 0 (0)| 00:00:01 | | | Q1,06 | PCWP | |
    |* 60 | INDEX UNIQUE SCAN | Dim 6 Index | 1 | | | 0 (0)| 00:00:01 | | | Q1,06 | PCWP | |
    DB Version is 10g R2:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    "CORE     10.2.0.4.0     Production"
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
    NLSRTL Version 10.2.0.4.0 - Production

  • Space used by tables

    in a production environment we are short of disk space. we need to know which tables are occupying the high amount of space from all the tablespaces present in the database, so that we can delete some data (if possible ) from those tables. any sql query to do this task in short amount of time.
    Thanx in Advance.

    Hi Abhishek,
    "Seeking help is not a frailty".
    Below query might help you.
    COLUMN TABLE_NAME FORMAT A32
    COLUMN OBJECT_NAME FORMAT A32
    COLUMN OWNER FORMAT A10
    SELECT owner, table_name, TRUNC(sum(bytes)/1024/1024) Meg
    FROM (SELECT segment_name table_name, owner, bytes
    FROM dba_segments WHERE segment_type = 'TABLE'
    UNION ALL
    SELECT i.table_name, i.owner, s.bytes
    FROM dba_indexes i, dba_segments s
    WHERE s.segment_name = i.index_name AND s.owner = i.owner AND s.segment_type = 'INDEX'
    UNION ALL
    SELECT l.table_name, l.owner, s.bytes
    FROM dba_lobs l, dba_segments s
    WHERE s.segment_name = l.segment_name AND s.owner = l.owner AND s.segment_type = 'LOBSEGMENT'
    UNION ALL
    SELECT l.table_name, l.owner, s.bytes
    FROM dba_lobs l, dba_segments s
    WHERE s.segment_name = l.index_name AND s.owner = l.owner AND s.segment_type = 'LOBINDEX')
    WHERE owner in UPPER('&owner') GROUP BY table_name, owner HAVING SUM(bytes)/1024/1024 > 10 /* Ignore really small tables */ ORDER BY SUM(bytes) desc ;
    Thanks and Regards,
    Auroeis
    Edited by: 939781 on Jun 27, 2012 2:19 AM

  • Determining the space used by data in a table at the granularity of bytes

    The SPACE_USAGE procedure of DBMS_SPACE package
    is meant for knowing space table with auto segment
    space management.
    It gives out 4 types of values fs1_blocks to
    fs4_blocks as the number of blocks which are filled
    25%, 50%, ....
    I tried it with different number of records (including)
    and empty table) but all 4 fields are always output as
    zero.
    Basically my aim is to know the actual amount of space
    used by my data in the table for both auto segment
    allocation and non auto mode.

    To have this kind of information I've used the function
    DBMS_SPACE.UNUSED_SPACE, that reporting:
    TOTAL_BLOCKS - data allocation space (in blocks)
    TOTAL_BYTES - data allocation space (in bytes)
    UNUSED_BLOCKS - allocated space but not used (in blocks)
    UNUSED_BYTES - allocated space but not used (in bytes)
    The difference between TOTAL_BYTES and UNUSED_BYTES is the REAL SIZE of your data.
    I don't know if you can use the same function for table with auto segment space management.
    Bye L.

  • 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

  • Use of Logical Partition in a Oracle Table...

    What is the use of Logical Partition in a Oracle Table as Target.  Techincal Manual does not say any significance.
    My question is:
    If the Table has no partitions and if we add Logical Partitions using Data Service, what purpose will it serve?
    We are planning to load 30 Million records a day into a Oracle Table. As of now the Target table has no partition and we are planning to have that soon. Is there a better way to load the data into Target Table, using Partition, Bulk Loading(API), Degree of Parallelism, etc., We have not dealt data of that volume, inputs are highly appreciated.
    Regards.
    Santosh.

    Initial Value:
    Indicator that NOT NULL is forced for this field
    Use
    Select this flag if a field to be inserted in the database is to be filled with initial values. The initial value used depends on the data type of the field.
    Please note that fields in the database for which the this flag is not set can also be filled with initial values.
    When you create a table, all fields of the table can be defined as NOT NULL and filled with an initial value. The same applies when converting the table. Only when new fields are added or inserted, are these filled with initial values. An exception is key fields. These are always filled automatically with initial values.
    Restrictions and notes:
    The initial value cannot be set for fields of data types LCHR, LRAW, and RAW. If the field length is greater than 32, the initial flag cannot be set for fields of data type NUMC.
    If a new field is inserted in the table and the initial flag is set, the complete table is scanned on activation and an UPDATE is made to the new field. This can be very time-consuming.
    If the initial flag is set for an included structure, this means that the attributes from the structure are transferred. That is, exactly those fields which are marked as initial in the definition have this attribute in the table as well.
    hope it helps,
    Saipriya

  • Steps to Increase / adding New Table Space using BR TOOLS

    Hi
    Can Anyone Tell me the Step by Step Process for Increasing / Adding New Table Space using BRTOOLS.
    Any Demos/Blogs will be appreciated.
    Thanks in Advance.
    Rg
    Dan

    Hi Dan,
    <u><b>Adding a datafile using BRTOOLS</b></u>
    1) su – <b>ora<sid></b>
    2) start <b>brtools</b>
    3) Select option <b>2 -- Space management</b>
    4) Select option <b>1 -- Extend tablespace</b>
    5) Select option <b>3 --Tablespace name (specify tablespace name) and say continue(c- cont)</b>
    6) Select option <b>3 – New data file to be added and return</b>
    7) Select option <b>5 -- Size of the new file in MB (specify the size of the file) and say continue</b>
    regards,
    kanthi

  • This disk doesn't use the GUID Partition table scheme.

    When I Install the Lion. It is stuck.
    Lion This disk doesn’t use the GUID Partition table scheme.Use disk Utility to change the partition scheme.Select the disk,choose the Partition tab,select the Volume Scheme and then click Options.
    The last step has problem.
    I can not click Options.

    In order to repartition the startup drive you will have to boot from your Snow Leopard DVD, select Utilities and then Disk Utility.  YOU MUST ERASE YOUR DISK TO CHANGE THE PARTITION TABLE.  The good news is that I see you have a Time Machine backup.  Make sure that your backup is current before you erase your startup disk.
    Even before doing this, save a copy of the Lion installer (it is in the Applications folder) onto an external device.  Your external hard drive is a good spot; it won't interfere with your Time Machine backup. This will prevent you from having to download the installer again.
    The easiest way to proceed after making sure your Time Machine backup is current, saving a copy of the Lion installer, and repartitioning your startup disk, is to reinstall Snow Leopard on your newly partitioned disk. This will take a little longer but it is simple and is fully supported by Apple.  Once that is done and you are running Snow Leopard on your startup disk again, run the Lion installer from whereever you saved it, and then restore your files and settings from your Time Machine backup during the install process.
    There is an unsupported procedure for making a bootable Lion DVD, but it is more complex and is not supported by Apple.  If you are uncomfortable with any of this and have access to an Apple Store, make an appointment at the Genius Bar and they can help you through the process.

  • Lion This disk doesn't use the GUID partition table scheme

    Hi I have downloaded and began running the installation but it says "This disk doesn't use the GUID partition table scheme", any ideas?! Running latest version of OSX 10.6.8
    Thanks in advance!

    ok, sorry if I offended you for wrong.
    I did not knew Apple ships MBR partitioned disks or has official support for doing so. I always see Windows-PCs with that scheme ( Linux supports mbr and guid just like osx ) .
    Of course I know that Disk Utility offers three options : GUID or MBR or Apple partition map for ppc devices.
    Lion needs GUID, so a reformat is absolutely necessary for those that have one of the others.
    Again sorry.

  • HT5225 "This disc does not use the GUID Partition Table Scheme...". I keep getting this message when I try to install OSXLion. It has something to do with a repair Apple performed last year. I use a 17" MacBookPro. Any suggestions?

    "This disc does not use the GUID Partition Table Scheme. Use Disc Utility to change the partition scheme". I keep getting this message when I try to install OSX Lion so that I can upgrade my 17" MacBookPro to move to iCloud. My harddrive was replaced last year by Apple because of a fault by the manufacturer and I think this is the cause of the problem. What can I do so that I don't lose my content.

    When you click the partion tab. There is option on the bottom of the window. Click on that there there are these options.

  • My IPhone 4S has 9GB of "other" space used.  How do I determine what "other" is.  I need to make space to upgrade my phone to IOS 8.1.1

    I have a IPhone 4S running IOS 7.1.2.  I want to upgrade to IOS 8.1.1.  I have 2 GB of free space.  I have 9GB of "other" space used.  How do I determine what "other" is and how do I delete some of it to make room to upgrade?

    What is "Other" and What Can I Do About It?

Maybe you are looking for