The reason why exp cannot export an empty table

 Reprinted: http://www.jb51.net/article/43894.htm

 

1. Oracle11g does not allocate segments to empty tables by default, so when using exp to export Oracle11g database, empty tables will not be exported.

2. After setting the deferred_segment_creation parameter to FALSE, segments are allocated regardless of whether it is an empty table or a non-empty table.

In sqlplus, execute the following command:

SQL>alter system set deferred_segment_creation=false;

Check:

SQL>show parameter deferred_segment_creation;

After this value is set, it only affects the newly added table, and has no effect on the empty table created before.

Second, the solution

The problem of exporting the empty table created before can be solved by manually assigning Extent to the empty table.

①select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 or num_rows is null

Using the above statement will concatenate the statement that assigns Extent to the empty table

However, there are many empty tables whose num_rows in the view user_tables is not equal to 0 (reason: there was data in the table before, Oracle has no statistics after deletion, and the data in the view user_tables is not updated), so the above method cannot be used for all empty tables. The table allocates data segments, the solution is as follows

②select 'analyze table '||table_name||' compute statistics;' from user_tables

analyze table tablename compute statistics is
equivalent to analyze table tablename compute statistics for table for all indexes for all columns
for table The statistics exist in the view: user_tables, all_tables, dba_tables
for all indexes The statistics exist in the view: user_indexes, all_indexes, dba_indexes
 for Statistics for all columns exist in the attempts: user_tab_columns, all_tab_columns, dba_tab_columns

After the execution, the num_rows value in the view user_tables will be updated. At this time, execute ① again to allocate data segments to all empty tables.

However, when executing analyze table tablename compute statistics, oracle will report object statictis are locked (the statistics of these tables are locked), which can be unlocked in the following way

 ③select 'exec dbms_stats.unlock_table_stats('||'''JXDEMO'''||','''||table_name||''');' from user_tables

(③The obtained result needs to be executed on sqlplus, and an error will be reported in the sql window in pl/sql developer)

③The result obtained after execution is executed and then go to execution ②There is no object statictis are locked error prompt

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326943274&siteId=291194637