How to export empty tables in oracle 11g
Due to the new features created by the delay segments of oracle 11g, oracle does not allocate data segments when no data is inserted. In this case, exp cannot export empty tables of the 11g Database.
Of course, this problem does not exist when expdp is used.
Expdp hr/hr schemas = hr dumpfile = expdp. dmp directory = dbtest
Conn hr/hr
Select TABLE_NAME, NUM_ROWS from user_tables;
TABLE_NAME NUM_ROWS
----------------------------------------
LOCATIONS 23
EMP_1 0
PART_TIME_EMPLOYEES 0
TEST3 5
TEST1 5
TEST 5
PC_WELL_TEST 2
PC_ALARM_SORT_TEST 1
MVIEW_PC_WELL_TEST 2
MV_CAPABILITIES_TABLE 14
T 0
TEST2
SYS_EXPORT_SCHEMA_01
SYS_EXPORT_SCHEMA_02
HOURLY_EMPLOYEES 0
COUNTRIES 25
ADMIN_EXT_EMPLOYEES
ADMIN_WORK_AREA
EMPLOYEES 107
Ments 27
DIGITS 2
REGIONS 4
JOB_HISTORY 10
JOBS 19
24 rows selected.
Why is num_rows empty here?
That's because the table has just been created, and the data dictionary does not have the statistical information related to this table.
SQL> select 'alter table' | table_name | 'allocate extent; 'from user_tables where
Num_rows = 0
'Altertable' | TABLE_NAME | 'allocateextent ;'
-----------------------------------------------------------
Alter table PART_TIME_EMPLOYEES allocate extent;
Alter table EMP_1 allocate extent;
Alter table T allocate extent;
Alter table HOURLY_EMPLOYEES allocate extent;
Therefore, for some online users that use manual extent allocation on oracle11g and then use exp to export the database, the actual effect is not very good, instead, it is much more convenient to directly use expdp to export the empty tables of the oracle 11g Database.
Of course, this method can still be used for those who want to import the earlier version from 11g, but pay attention to either analyzing all the relevant tables and then using the above batch script. Alternatively, you can manually use ue to edit the command for allocating extent without analyzing the table.
SQL> select TABLE_NAME, NUM_ROWS from user_tables where NUM_ROWS = 0;
TABLE_NAME NUM_ROWS
----------------------------------------
PART_TIME_EMPLOYEES 0
EMP_1 0
T 0
HOURLY_EMPLOYEES 0
Additional information:
USER_TABLES describes the relational tables owned by the current user. Its columns (partition t
For OWNER) are the same as those in ALL_TABLES. To gather statistics for this view, use
DBMS_STATS package.
Collect table statistics:
Analyze table xxx compute statistics;
Or
Exec dbma_stats.gather_table_stats ('user', 'table ');