Load a JSON File of Line-Delimited Documents into a Collection
For loading
data from collections in the Cloud, you must first store your object storage credentials in your
Autonomous Database and then use the procedure DBMS_CLOUD.COPY_COLLECTION
to load documents into a
collection.
This example loads JSON values from a line-delimited file and uses the JSON
file myCollection.json
. Each value, each line, is loaded into a
collection on your JSON database as a
single document.
Here's an example of such a file. It has three lines, with one object per line. Each of those objects gets loaded as a separate JSON document.
{ "name" : "apple", "count": 20 }
{ "name" : "orange", "count": 42 }
{ "name" : "pear", "count": 10 }
Before loading the data from myCollection.json
into your
database, copy the file to your object store:
-
Create a bucket in the object store. For example, create an Oracle Cloud Infrastructure Object Storage bucket from the Oracle Cloud Infrastructure Object Storage link, and then in your selected compartment click Create Bucket, or use a command such as the following OCI CLI command to create a bucket:
oci os bucket create --name fruit_bucket -c <compartment id>
-
Copy the JSON file to your object store bucket. For example use the following OCI CLI command to copy the JSON file to the
fruit_bucket
on Oracle Cloud Infrastructure Object Storage:oci os object put --bucket-name fruit_bucket \ --file "myCollection.json"
Load the JSON file from object store into a collection named
fruit
on your JSON database as follows:
Parent topic: Load JSON