Load Data from a CSV File with a Line Break in the Data

This provides an example using the 'csv with embedded' option to load data from a CSV file with a line break in the data.

For this example, the CSV file has the following data:

ID,NAME,NOTES
1,Alice,"Alice said, ""Hello!"""
2,Bob,"Bob's note
spans multiple lines."
  1. From the console, select the compartment for your Autonomous AI Database, and then select the link to your Autonomous AI Database to open the console.

    Note:

    These steps are shown using Database Actions to execute the PL/SQL code, and query the data. These actions can be performed from any SQL connection, connecting to the Autonomous AI Database as a user with the proper privileges.
  2. On the Autonomous AI Database Details page select Database Actions and in the list click SQL.

    As an alternative, select Database Actions and click View all database actions to access the Database Actions Launchpad. From the Development section of the Database Actions Launchpad, select SQL.

  3. Within the SQL Worksheet, enter and execute the following code:
    BEGIN DBMS_CLOUD.CREATE_EXTERNAL_TABLE(
                 table_name      => 'MY_TABLE',
                 credential_name => 'MY_OBJECT_STORAGE_CRED',
                 file_uri_list   => 'https://objectstorage.region.oraclecloud.com/n/namespace/b/bucket/o/my_embedded.csv',
                 format          =>  json_object('type' value 'csv with embedded', 'skipheaders' value '1'),
    );
    END;
    /

    The 'type' value 'csv with embedded' tells Oracle to correctly interpret embedded line breaks and quoted strings, while the 'skipheaders' value '1' skips the first header row.