Use Oracle Database Actions with SODA
You can use Oracle Database Actions to work with SODA collections directly, using its built-in SODA commands. Database Actions provides a browser-based development environment and a data modeler interface for Autonomous JSON Database.
See Connect with Built-In Oracle Database Actions for information about connecting to Database Actions.
A common set of SODA command-line commands are provided by Database Actions and Oracle SQL Developer Command Line, SQLcl. SQLcl is a Java-based command-line interface for Oracle Database. You can use it to execute SQL and PL/SQL statements interactively or in batch. It provides inline editing, statement completion, command recall, and it supports existing SQL*Plus scripts.
See SODA Commands in Using Oracle Database Actions for complete information about the SODA command-line commands.
See Oracle video Demonstration: Using Autonomous Transaction Processing (ATP) Service as a JSON Document Store, for a demonstration of the examples shown here
You enter commands in the Worksheet area of Database Actions, click the green right-arrow, and see results and other information in the tabs below the worksheet. The simple examples here create a collection, insert a JSON document into the collection, and query the collection.
-
Create a collection named
emp
.soda create emp
The creation is echoed in tab Script Output, below the worksheet.
-
List the existing SODA collections, using command
soda list
.soda list
The list, shown in Script Output, includes collection
emp
. -
Insert five JSON documents into the collection, one by one.
soda insert emp {"name" : "Blake", "job" : "Intern", "salary" : 30000} soda insert emp {"name" : "Smith", "job" : "Programmer", "salary" : 80000} soda insert emp {"name" : "Miller", "job" : "Programmer", "salary" : 90000} soda insert emp {"name" : "Clark", "job" : "Manager", "salary" : 100000} soda insert emp {"name" : "King", "job" : "President", "salary" : 200000, "email" : "king@example.com"}
Each insertion is echoed in Script Output.
-
Get (retrieve) documents, filtering the collection with a SODA query-by-example (QBE) pattern that matches
"Miller"
as the name. (Switch-f
means list the documents that match the QBE.)soda get emp -f {"name":"Miller"}
Script Output shows the one matching document that's selected (returned), along with the key for that document, which is a universally unique identifier (UUID) that identifies it.
-
Get the documents that have a salary field whose value is at least 50,000. The QBE pattern uses SODA greater-than-or-equal operator,
$ge
, comparing target fieldsalary
, with the value 100,000.soda get emp -f {"salary" : {"$ge" : 100000}}
Two documents are returned in this case, for employees Clark, and King, each of whose salary is at least 100,000.