Pregunta

The exclude parameter can be used to filter out schema objects during export in Oracle Data Pump.

EXCLUDE=object_type[:name_clause] [, ...]

Is table partition a valid object_type?

In other words, is it posible to exclude selected table partitions during export?

¿Fue útil?

Solución 2

It seems the only way to include/exclude selected partitions during export is to use the datapump API. Following is an eample:

http://www.acehints.com/2011/06/data-pump-expdp-how-to-exclude-table.html

Otros consejos

The section of the documentation that covers filtering during export operations says:

Metadata filtering is implemented through the EXCLUDE and INCLUDE parameters...

Metadata filters identify a set of objects to be included or excluded from an Export or Import operation...

To see a list of valid object types, query the following views: DATABASE_EXPORT_OBJECTS for full mode, SCHEMA_EXPORT_OBJECTS for schema mode, and TABLE_EXPORT_OBJECTS for table and tablespace mode. The values listed in the OBJECT_PATH column are the valid object types.

The first two views on my 11gR2 (EE) instance do not have any references to partitions; the third has some that refer to DBMS_PLUGTS, which doesn't appear in the PL/SQL Packages and Types Reference section, but seems to be for transportable tablespaces.

Not definitive, but based on that I'd have to say no, at least as separate object type.

So how about using the table:partition syntax that's valid in the TABLES clause? This doesn't work; if you try to include the partition name in the EXCLUDE clause:

expdp tables=MY_TABLE exclude=table:"= 'MY_TABLE:SOME_PARTITION'" ...

... it's ignored and the whole table is still exported - it seems to be treating the : as part of the table name, which isn't entirely unreasonable as it's in quotes, and therefore doesn't match against the table you're exporting at all. Same if you specify a schema to export, rather than just that table.

The only option you seem to have is to specify the partitions you do want in the TABLES clause.

You cannot exclude a table partition, using the TABLE key-word, what you want to do is to exclude the TABLE_DATA.

exclude=table_data:"in ('SOME_PARTITION','SOME_OTHER_PARTITION')"

The manuals actually explains that.

Unfortuanately any table_data matching will be excluded. This is really great if you partition your tables by period as in:
TRANSACTION.PD2010
TRANSACTION.PD2011
TRANSACTION.PD2012
TRANSACTION.PD2013
TRANSACTION_DETAIL.PD2010
TRANSACTION_DETAIL.PD2011
TRANSACTION_DETAIL.PD2012
TRANSACTION_DETAIL.PD2013
The partition names should not be the same as any table names, but you did of course take care of that when you planned the partitioning.
You can now do the exclude as follows:

exclude=table_data:"in (select partition_name from user_partitions where partition_name like 'PD%' and partition_name < 'PD' || to_char(sysdate,'YYYY'))"

You can also do the include the same way, using a select statement instead of a list of tables, that way you can get around the 4000 characters line limit. That can also be circumvented by multiple include statements, or by adding line breaks to the list of tables, however I do believe that if you have an in list, there can be only 1000 objects in that list, you can also do a table export, which exports only the tables, not the modules, triggers etc. That list is not limited to 1000 and again you can get around the 4000 character limit by adding line breaks.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top