一、Oracle數據庫查看表情況
1、查看表情況及表記錄數(記錄數來自統計信息,不是精准的)
建議移植前先使用DBMS_STATS收集下統計信息。
Select t.Table_Name, t.Partitioned, t.Num_Rows
From User_Tables t
Order By t.Partitioned, t.Num_Rows Desc
2、生成查詢精確各表數據量
因查詢是實時根據數據庫數據情況進行統計,如數據量較大,非常消耗資源,建議根據上一步查詢的初步表數據量信息,分段執行。
Select 'select ''' || t.Table_Name || ''',count(*) from ' || t.Table_Name ||
' union'
From User_Tables t
Order By t.Num_Rows Desc
3、查看分區表情況
(1)查詢分區表具體情況
Select t.Table_Name,
t.Partitioning_Type,
t.Subpartitioning_Type,
t.Partitioning_Key_Count,
t.Subpartitioning_Key_Count,
t.Interval
From User_Part_Tables t
Where t.Status = 'VALID'
(2)統計分區表數量
Select t.Table_Name, Count(*)
From User_Tab_Partitions t
Group By t.Table_Name
Order By t.Table_Name
二、postgreSQL數據庫查詢表情況
1、即包含分區表,也包括分區表的分區
select *
from pg_catalog.pg_tables t
where t.schemaname = 'test'
2、只查分區表的主表
select distinct tc.relname
from pg_catalog.pg_partitioned_table tp,
pg_catalog.pg_class tc,
pg_catalog.pg_namespace tn
where tp.partrelid = tc.oid
and tc.relnamespace = tn.oid
and tn.nspname = 'test'
3、只查分區表的分區
select *
from pg_catalog.pg_tables t
where t.schemaname = 'test'