Export Data to a Directory Using DBMS_CLOUD.EXPORT_DATA
Use DBMS_CLOUD.EXPORT_DATA to export files to a directory.
The directory to which you export files can be in the Autonomous AI Database file system or an attached external file system. See the following pages for more information:
Export Data as CSV to a Directory
Shows the steps to export table data from your Autonomous AI Database to a directory as CSV data by specifying a query.
-
Connect to your Autonomous AI Database instance.
See Connect to Autonomous AI Database for more information.
-
Create a directory.
For example:
CREATE DIRECTORY export_dir AS 'export_dir';See Create a Directory for more information.
-
Run
DBMS_CLOUD.EXPORT_DATAand specify theformatparametertypewith the valuejsonto export the results as CSV files to a directory. Do not include thecredentialparameter when sending output to a directory.BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => 'export_dir:sales.csv', format => JSON_OBJECT('type' value 'csv'), query => 'SELECT * FROM sales' ); END; /When record delimiters include escape characters, such as \r\n or \t, enclose the record delimiters in double quotes. For example, to use the record delimiter
\r\n, enclose the value in double quotes:"\r\n".BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => 'export_dir:sales.csv', query => 'SELECT * FROM sales', format => JSON_OBJECT('type' value 'json', 'recorddelimiter' value '"\r\n"' format json)); END; /The directory name is case-sensitive when the directory name is enclosed in double quotes. For example:
BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => '"export_dir":sales.csv', format => JSON_OBJECT('type' value 'csv'), query => 'SELECT * FROM sales' ); END; /For detailed information about the parameters, see EXPORT_DATA Procedure.
For detailed information about the available
formatparameters you can use withDBMS_CLOUD.EXPORT_DATA, see DBMS_CLOUD Package Format Options for EXPORT_DATA.The parameters are:
-
file_uri_list: is a comma delimited list of the export file(s). Use of wildcard and substitution characters is not supported in thefile_uri_list. -
format: specifies the requiredtypeparameter. The valid values arejson,xml, andcsv. -
query: specifies aSELECTstatement so that only the required data is exported. The query determines the contents of the dump file(s).
Note: The
DBMS_CLOUD.EXPORT_DATAprocedure creates the dump file(s) that you specify in thefile_uri_list. The procedure does not overwrite files. If a dump file in thefile_uri_listexists,DBMS_CLOUD.EXPORT_DATAgenerates another file with a unique name.DBMS_CLOUD.EXPORT_DATAdoes not create directories.For detailed information about the parameters, see EXPORT_DATA Procedure.
-
Notes for exporting with DBMS_CLOUD.EXPORT_DATA:
-
The
queryparameter that you supply can be an advanced query, if required, such as a query that includes joins or subqueries. -
Specify the
formatparameter with thecompressionoption to compress the output files.
Export Data as JSON a Directory
Shows the steps to export table data from your Autonomous AI Database to a directory as JSON data by specifying a query.
-
Connect to your Autonomous AI Database instance.
See Connect to Autonomous AI Database for more information.
-
Create a directory.
For example:
CREATE DIRECTORY export_dir AS 'export_dir';See Create a Directory for more information.
-
Run
DBMS_CLOUD.EXPORT_DATAand specify theformatparametertypewith the valuejsonto export the results as JSON files to a directory. Do not include thecredentialparameter when sending output to a directory.BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => 'export_dir:sales.dmp', format => json_object('type' value 'json'), query => 'SELECT * FROM sales' ); END; /When record delimiters include escape characters, such as \r\n or \t, enclose the record delimiters in double quotes. For example, to use the record delimiter
\r\n, enclose the value in double quotes:"\r\n".BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => 'export_dir:sales.dmp', query => 'SELECT * FROM sales', format => JSON_OBJECT('type' value 'json', 'recorddelimiter' value '"\r\n"' format json)); END; /The directory name is case-sensitive when the directory name is enclosed in double quotes. For example:
BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => '"export_dir":sales.dmp', format => json_object('type' value 'json'), query => 'SELECT * FROM sales' ); END; /For detailed information about the parameters, see EXPORT_DATA Procedure.
For detailed information about the available
formatparameters you can use withDBMS_CLOUD.EXPORT_DATA, see DBMS_CLOUD Package Format Options for EXPORT_DATA.The parameters are:
-
file_uri_list: is a comma delimited list of the export file(s). Use of wildcard and substitution characters is not supported in thefile_uri_list. -
format: specifies the requiredtypeparameter. The valid values arejson,xml, andcsv. -
query: specifies aSELECTstatement so that only the required data is exported. The query determines the contents of the dump file(s).
Note: The
DBMS_CLOUD.EXPORT_DATAprocedure creates the dump file(s) that you specify in thefile_uri_list. The procedure does not overwrite files. If a dump file in thefile_uri_listexists,DBMS_CLOUD.EXPORT_DATAgenerates another file with a unique name.DBMS_CLOUD.EXPORT_DATAdoes not create directories.For detailed information about the parameters, see EXPORT_DATA Procedure.
-
Notes for exporting with DBMS_CLOUD.EXPORT_DATA:
-
The
queryparameter that you supply can be an advanced query, if required, such as a query that includes joins or subqueries. -
Specify the
formatparameter with thecompressionoption to compress the output files.
Export Data as Parquet to a Directory
Shows the steps to export table data from your Autonomous AI Database to a directory as Parquet data by specifying a query.
-
Connect to your Autonomous AI Database instance.
See Connect to Autonomous AI Database for more information.
-
Create a directory.
For example:
CREATE DIRECTORY export_dir AS 'export_dir';See Create a Directory for more information.
-
Run
DBMS_CLOUD.EXPORT_DATAand specify theformatparametertypewith the valuejsonto export the results as Parquet files to a directory. Do not include thecredentialparameter when sending output to a directory.BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => 'export_dir:sales.parquet', format => JSON_OBJECT('type' value 'parquet'), query => 'SELECT * FROM sales' ); END; /The directory name is case-sensitive when the directory name is enclosed in double quotes. For example:
BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => '"export_dir":sales.parquet', format => JSON_OBJECT('type' value 'parquet'), query => 'SELECT * FROM sales' ); END; /For detailed information about the parameters, see EXPORT_DATA Procedure.
For detailed information about the available
formatparameters you can use withDBMS_CLOUD.EXPORT_DATA, see DBMS_CLOUD Package Format Options for EXPORT_DATA.The parameters are:
-
file_uri_list: is a comma delimited list of the export file(s). Use of wildcard and substitution characters is not supported in thefile_uri_list. -
format: specifies the requiredtypeparameter. The valid values aredatapump,json,xml,csvandparquetand it also optionally defines the options you can specify for the export with theORACLE_DATAPUMPAccess Driver. -
query: specifies aSELECTstatement so that only the required data is exported. The query determines the contents of the dump file(s).
For detailed information about the parameters, see EXPORT_DATA Procedure.
-
Notes for exporting with DBMS_CLOUD.EXPORT_DATA:
-
The
queryparameter that you supply can be an advanced query, if required, such as a query that includes joins or subqueries. -
Specify the
formatparameter with thecompressionoption to compress the output files. -
See DBMS_CLOUD Package Oracle Data Type to Parquet Mapping for details on Oracle Type to Parquet Type mapping.
The following types are not supported or have limitations on their support for exporting Parquet with
DBMS_CLOUD.EXPORT_DATA:Oracle Type Notes BFILENot supported BLOBNot supported DATESupported with the following limitation:
DATEformat supports only date, month and year. Hour, minute and seconds are not supported.See DBMS_CLOUD Package Oracle Data Type to Parquet Mapping for details on NLS format limitations for exporting
DATEto Parquet.INTERVAL DAY TO SECONDSupported and is treated as string internally INTERVAL YEAR TO MONTHSupported and is treated as string internally LONGNot supported LONG RAWNot supported NUMBERSupported with the following limitations:
- Can have maximum precision of 38 and scale equal to less than precision.
- If no precision and scale is provided for the columnNUMBERtype, by default precision of 38 and scale of 20 is used.
- Negative scale is not supported forNUMBERtypes.Object TypesNot supported TIMESTAMPSupported with the following limitations:
- If there are multiple columns with different precision, highest precision will be taken.
-TIMESTAMP WITH TIME ZONEOracle datatype will use the timestamp only.
See DBMS_CLOUD Package Oracle Data Type to Parquet Mapping for details on NLS format limitations for exportingTIMESTAMPto Parquet.
Export Data as XML to a Directory
Shows the steps to export table data from your Autonomous AI Database to Directory as XML data by specifying a query.
-
Connect to your Autonomous AI Database instance.
See Connect to Autonomous AI Database for more information.
-
Create a directory.
For example:
CREATE DIRECTORY export_dir AS 'export_dir';See Create a Directory for more information.
-
Run
DBMS_CLOUD.EXPORT_DATAand specify theformatparametertypewith the valuejsonto export the results as XML files to a directory. Do not include thecredentialparameter when sending output to a directory.BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => 'export_dir:sales.csv', format => JSON_OBJECT('type' value 'csv'), query => 'SELECT * FROM sales' ); END; /The directory name is case-sensitive when the directory name is enclosed in double quotes. For example:
BEGIN DBMS_CLOUD.EXPORT_DATA( file_uri_list => '"export_dir":sales.xml', format => JSON_OBJECT('type' value 'xml'), query => 'SELECT * FROM sales' ); END; /For detailed information about the parameters, see EXPORT_DATA Procedure.
For detailed information about the available
formatparameters you can use withDBMS_CLOUD.EXPORT_DATA, see DBMS_CLOUD Package Format Options for EXPORT_DATA.The parameters are:
-
file_uri_list: is a comma delimited list of the export file(s). Use of wildcard and substitution characters is not supported in thefile_uri_list. -
format: specifies the requiredtypeparameter. The valid values arejson,xml, andcsv. -
query: specifies aSELECTstatement so that only the required data is exported. The query determines the contents of the dump file(s).
Note: The
DBMS_CLOUD.EXPORT_DATAprocedure creates the dump file(s) that you specify in thefile_uri_list. The procedure does not overwrite files. If a dump file in thefile_uri_listexists,DBMS_CLOUD.EXPORT_DATAgenerates another file with a unique name.DBMS_CLOUD.EXPORT_DATAdoes not create directories.For detailed information about the parameters, see EXPORT_DATA Procedure.
-
Notes for exporting with DBMS_CLOUD.EXPORT_DATA:
-
The
queryparameter that you supply can be an advanced query, if required, such as a query that includes joins or subqueries. -
Specify the
formatparameter with thecompressionoption to compress the output files.