You are on page 1of 2

Partition

https://docs.oracle.com/cd/E18283_01/server.112/e16541/part_admin005.htm

https://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin005.htm
http://www.orafaq.com/wiki/Partitioning_FAQ

ALL_TAB_PARTITIONS

exec dbms_stats.gather_table_stats(user, 't', cascade => true);

1.
A simple query against the data dictionary will show if a given table or index is
partitioned or not:

SELECT * FROM dba_part_tables;


SELECT * FROM dba_part_indexes;
-----------------------------------------------------------------------

2.
SELECT * FROM dba_tab_partitions WHERE table_name = '<table_name>';
One can show the partitions of an given index with:

SELECT * FROM dba_ind_partitions WHERE index_name = '<index_name>';

=========================================================================
3. check rows

SELECT
TABLE_NAME, PARTITION_NAME, PARTITION_POSITION, HIGH_VALUE
FROM
Remote DBA_TAB_PARTITIONS
WHERE
TABLE_NAME='POS_DATA'
ORDER BY
PARTITION_NAME;

====================================================================
4.
How to count records per ranged partition within a single select in oracle 12c?
SELECT table_name, partition_name, subpartition_name, num_rows
FROM dba_tab_partitions;

========================================================================

5.

Below script is for finding the row counts of all partitions of a table in Oracle.

set serverout on size 1000000


set verify off
declare
sql_stmt varchar2(1024);
row_count number;
cursor get_tab is
select table_name,partition_name
from dba_tab_partitions
where table_owner=upper('&&TABLE_OWNER') and table_name='&&TABLE_NAME';
begin
dbms_output.put_line('Checking Record Counts for table_name');
dbms_output.put_line('Log file to numrows_part_&&TABLE_OWNER.lst ....');
dbms_output.put_line('....');
for get_tab_rec in get_tab loop
BEGIN
sql_stmt := 'select count(*) from &&TABLE_OWNER..'||get_tab_rec.table_name
||' partition ( '||get_tab_rec.partition_name||' )';

EXECUTE IMMEDIATE sql_stmt INTO row_count;


dbms_output.put_line('Table '||rpad(get_tab_rec.table_name
||'('||get_tab_rec.partition_name||')',50)
||' '||TO_CHAR(row_count)||' rows.');
exception when others then
dbms_output.put_line
('Error counting rows for table '||get_tab_rec.table_name);
END;
end loop;
end;
/
set verify on

DBACLASS
Search.....
HOME / DATABASE SCRIPTS / FIND ROW COUNT OF ALL PARTITIONS OF A TABLE
Find Row Count Of All Partitions Of A Table
768 views Less than a minute 0

You might also like