Skip Headers

Oracle® XML DB Developer's Guide
10g Release 1 (10.1)

Part Number B10790-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

28 Importing and Exporting XMLType Tables

This chapter describes how you can import and export XMLType tables for use with Oracle XML DB.

It contains the following sections:

Overview of IMPORT/EXPORT Support in Oracle XML DB

Oracle XML DB supports XMLType tables and columns that can store XML data and be based on a registered XML schema. Tables storing XML schema-based or non-schema-based data can be imported and exported.

Resources and Foldering Do Not Fully Support IMPORT/EXPORT

Oracle XML DB also supports a foldering mechanism in the database that provides a file-system like paradigm to database data. This model uses path names and URIs to refer to data (referred to as resources) rather than table names, column names, and so on. This release however does not support this paradigm using IMPORT/EXPORT.

However for resources based on a registered XML schema, the actual XMLType tables storing the data can be exported and imported. This implies that only the XML data is exported while the relationship in the Oracle XML DB foldering hierarchy would be lost.

Non-XML Schema-Based XMLType Tables and Columns

XMLType tables and columns can be created without any XML schema specification in which case the XML data is stored in a CLOB.

Data from these tables can be exported and imported in a manner similar to LOB columns. The export dump file stores the actual XML text.

XML Schema-Based XMLType Tables

Oracle supports the export and import of XML schema-based XMLType tables. An XMLType table depends on the XML schema used to define it. Similarly the XML schema has dependencies on the SQL object types created or specified for it. Thus, exporting a user with XML schema-based XMLType tables, consists of the following steps:

  1. Exporting SQL Types During XML Schema Registration. As a part of the XML schema registration process, SQL types can be created. These SQL types are exported as a part of CREATE TYPE statement along with their OIDs.

  2. Exporting XML Schemas. After all the types are exported, XML schemas are exported as XML text as part of the DBMS_XMLSCHEMA.REGISTERSCHEMA statement. In this statement:

  3. Exporting XML Tables. The next step is to export the tables. Export of each table consists of two steps:

    1. The table definition is exported as a part of the CREATE TABLE statement along with the table OID.

    2. The data in the table is exported as XML text. Note that data for out-of-line tables is not explicitly exported. It is exported as a part of the data for the parent table.


      Note:

      OCTs and nested tables are not exported separately. They are exported as parts of the parent table.

Guidelines for Exporting Hierarchy-Enabled Tables

The following describes guidelines for exporting hierarchy-enabled tables:

  • The RLS policies and path-index triggers are not exported for hierarchy-enabled tables. This implies that when these tables are imported, they are not hierarchy-enabled.

  • Hidden columns ACLOID and OWNERID are not exported for these tables. This is because in an imported database, the values of these columns could be different and hence should be re-initialized.

IMPORT/EXPORT Syntax and Examples

The IMPORT/EXPORT syntax and description are described in Oracle Database Utilities. This chapter includes additional guidelines and examples for using IMPORT/EXPORT with XMLType data.


IMPORT/EXPORT Example

Assumptions: The examples here assume that you are using a database with the following features:

User Level Import/Export

Example 28-1 Exporting XMLType Data

exp sytem/manager file=file1 owner=U1

This exports the following:

  • Any types that were generated during schema registration of schemas SL1 and SG1.

  • Schemas SL1 and SG1

  • Tables TL1 and TG1 and any other tables that were generated during schema registration of schemas SL1 and SG1.

  • Any data in any of the preceding tables.

Example 28-2 Exporting XMLType Tables

exp sytem/manager file=file2 owner=U2

This exports the following:

  • Table TG2 and any other tables that were generated during creation of TG2.

  • Any data in any of the preceding tables.


Note:

This does not export Schema SG1 or any types that were created during the registration of schema SG1.

Example 28-3 Importing Data from a File

imp system/manager file=file1 fromuser=U1 touser=newuser

This imports all the data in file1.dmp to schema newuser.

Import fails if the FROMUSER object types and object tables already exist on the target system. See "Considerations When Importing Database Objects" in Database Utilities.

Table Mode Export

An XMLType table has a dependency on the XML schema that was used to define it. Similarly the XML schema has dependencies on the SQL object types created or specified for it. Importing an XMLType table requires the existence of the XML schema and the SQL object types. When a TABLE mode export is used, only the table related metadata and data are exported. To be able to import this data successfully, the user needs to ensure that both the XML schema and object types have been created.

Example 28-4 Exporting XML Data in TABLE Mode

exp SYSTEM/MANAGER file=expdat.dmp tables=U1.TG1

This exports:

  • Table TG1 and any nested tables that were generated during creation of TG1.

  • Any data in any of the preceding tables.


    Note:

    This does not export schema SG1 or any types that were created during the registration of schema SG1.

Example 28-5 Importing XML Data in TABLE Mode

imp SYSTEM/MANAGER file=expdat.dmp fromuser=U1 touser=U2 tables=TG1

This creates table TG1 for user U2 because U2 already has access to the globals schema SG1 and the types that it depends on.

Import fails if the FROMUSER object types and object tables already exist on the target system. See "Considerations When Importing Database Objects" in Database Utilities.

Metadata in Repository is Not Exported During a Full Database Export

Oracle XML DB stores the metadata (and the non-schema data) for the repository in the XML DB database user schema. Because Oracle does not support the export of the repository structure, these metadata tables and structures are not exported during a full database export.

The entire XML DB ("XDB") user schema is skipped during a full database export and any database objects owned by XML DB ("XDB") are not exported.

Importing and Exporting with Different Character Sets

As with other database objects, XML data is exported in the character set of the exporting server. During import, the data gets converted to the character set of the importing server.