In this blogpost, we will see about how
to configure Oracle Database API for mongo DB using Oracle database 23ai. We
will be using Oracle Virtual box image, that comes with ORDS with Oracle
Database API for mongo DB enabled by default. The Oracle database version and
ORDS version for this demo is listed below.
demo@FREEPDB1> select
banner_full from v$version;
BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.5.0.24.07
demo@FREEPDB1> select
ords.installed_version ;
INSTALLED_VERSION
---------------------
24.3.0.r2620924
let’s create a database user account with
minimal privileges required to perform the work and REST enable it (REST enabling
schema is needed, for the database to accept the connections from Mongo Shell)
sys@FREEPDB1> grant
DB_DEVELOPER_ROLE,unlimited tablespace
2 to mdb_test2 identified by mdb_test2 ;
Grant succeeded.
sys@FREEPDB1> conn mdb_test2/mdb_test2@freepdb1
Connected.
mdb-test2@FREEPDB1> declare
2 pragma autonomous_transaction;
3 begin
4 ords.enable_schema(p_enabled => TRUE,
5 p_schema => 'MDB_TEST2',
6 p_url_mapping_type => 'BASE_PATH',
7 p_url_mapping_pattern => 'mdb_test2',
8 p_auto_rest_auth => FALSE);
9 commit;
10 end;
11 /
PL/SQL procedure successfully
completed.
mdb-test2@FREEPDB1>
to connect using the Mongo Shell from
command prompt we can use the following URI
C:\Users\Rajeshwaran>mongosh
--tls --tlsAllowInvalidCertificates
"mongodb://mdb_test2:mdb_test2@localhost:27017/mdb_test2?authMechanism=PLAIN&authSource=$external&ssl=true&retryWrites=false&loadBalanced=true"
Current Mongosh Log ID: 672f715fbd9017c3be86b01c
Connecting to: mongodb://<credentials>@localhost:27017/mdb_test2?authMechanism=PLAIN&authSource=%24external&ssl=true&retryWrites=false&loadBalanced=true&serverSelectionTimeoutMS=2000&tls=true&tlsAllowInvalidCertificates=true&appName=mongosh+2.3.2
Using MongoDB: 4.2.14
Using Mongosh: 2.3.2
For mongosh info see:
https://www.mongodb.com/docs/mongodb-shell/
mdb_test2>
mdb_test2> show
collections;
to connect using the MongoDB Compass we use the
following URI
--------------------------------------------------------------------------------
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.5.0.24.07
---------------------
24.3.0.r2620924
2 to mdb_test2 identified by mdb_test2 ;
Connected.
mdb-test2@FREEPDB1> declare
2 pragma autonomous_transaction;
3 begin
4 ords.enable_schema(p_enabled => TRUE,
5 p_schema => 'MDB_TEST2',
6 p_url_mapping_type => 'BASE_PATH',
7 p_url_mapping_pattern => 'mdb_test2',
8 p_auto_rest_auth => FALSE);
9 commit;
10 end;
11 /
Current Mongosh Log ID: 672f715fbd9017c3be86b01c
Connecting to: mongodb://<credentials>@localhost:27017/mdb_test2?authMechanism=PLAIN&authSource=%24external&ssl=true&retryWrites=false&loadBalanced=true&serverSelectionTimeoutMS=2000&tls=true&tlsAllowInvalidCertificates=true&appName=mongosh+2.3.2
Using MongoDB: 4.2.14
Using Mongosh: 2.3.2
After this we can insert data and
retrieve information (either from the MongoDB or SQL commands) from the Collection
that will be created on MongoDB. In the next blogpost, we will see about creating
Json Collections / documents through Oracle database API for Mongo DB and not
only access your data using NoSQL approach, but you can also use SQL based approach
on the same JSON collections.
In the next blogpost we will see how to manipulate these collections using SQL and MongoDB commands.
No comments:
Post a Comment