About Compartments
Learn how to specify the compartment while creating and working with Oracle NoSQL Database Cloud Service tables using Oracle NoSQL Database Drivers.
If you have been authenticated using an instance principal (accessing the service from an OCI compute instance), you must specify a compartment using its id (OCID), as there is no default in this case. See Calling Service From an Instance in Oracle Cloud Infrastructure Documentation.
- Use a default compartment in
NoSQLHandleConfig
so that it applies to all the operations using the handle. See Obtaining a NoSQL Handle for an example. - Use the compartment name or id (OCID) in each request in addition to the table
name. This overrides any default compartment.
For example:
GetRequest getReq = new GetRequest().setTableName("mytable") .setCompartment("mycompartment");
- Use the compartment name as a prefix on the table name. This overrides any
default compartment as well as a compartment specified using API.
For example:
GetRequest getReq = new GetRequest().setTableName("mycompartment:mytable");
Note:
While specifying the path to a nested compartment, do not include the top-level compartment's name in the path as that is inferred from the tenancy.- A method exists to allow specification of a default compartment for requests in
borneo.NoSQLHandleConfig.set_compartment()
. This overrides the user’s default compartment. - In addition, it is possible to specify a compartment in each
Request
instance.
set_compartment
methods take either an id (OCID) or a
compartment name or a path. If a compartment name is used it may be the name of a top-level
compartment.
Note:
If a compartment path is used to reference a nested compartment, the path is a dot-separate path that excludes the top-level compartment of the path, for example,compartmentA.compartmentB
.
...
request = PutRequest().set_table_name('mycompartment:mytable')
...
create_statement = 'create table mycompartment:mytable(...)'
...
request = GetRequest().set_table_name('compartmentA.compartmentB')
- You can set a desired compartment name or id.
- Set to an empty string to use the default compartment, that is the root compartment of the tenancy.
- If using a nested compartment, specify the full compartment path relative to the root
compartment as compartmentID. For example, if using
rootCompartment.compartmentA.compartmentB, the compartmentID should be set to
compartmentA.compartmentB
. - You can also use the compartment OCID as the string value.
compartmentID:="<optional-compartment-name-or-ID>"
iam.NewRawSignatureProvider(tenancy, user, region, fingerprint, compartmentID,
privateKey, &privateKeyPassphrase)
NoSQLClient
instance by setting the compartment property of the configuration
passed to the NoSQLClient
constructor:import { NoSQLClient,Region } from 'oracle-nosqldb';
const client = new NoSQLClient({
region: Region.US_ASHBURN_1,
compartment: 'mycompartment'
});
The string value may be either a compartment id or a compartment name or path. If it is a simple name it must specify a top-level compartment. If it is a path to a nested compartment, the top-level compartment must be excluded as it is inferred from the tenancy. A compartment can also be specified in each request in the options object. This value overrides the initial configuration value.
If you don't specify a compartment, the root compartment of the tenancy will be used as the default. This applies only if you are authorizing with specific user's identity. If you are using instance principal or resource principal for authentication, you must specify the compartment ID as there is no default in these cases.
If compartment is not supplied, the tenancy OCID will be used as default. Note this only applies if you are authorizing with user's identity. When using instance principal or resource principal, compartment id must be specified.
For the procedure to set up instance principal, seeCalling Services from an Instance. For the procedure to set up resource principal, see Accessing Other Oracle Cloud Infrastructure Resources from Running Functions.
NoSQLConfig
. For
example:var client = new NoSQLClient(
new NoSQLConfig
{
Region=Region.US_ASHBURN_1,
Compartment="<compartment_ocid_or_name>"
});
The
string value may be either a compartment OCID or a compartment name or path. If it is a simple
name it must specify a top-level compartment. If it is a path to a nested compartment, the
top-level compartment must be excluded as it is inferred from the tenancy.In addition, all operation options classes have Compartment
property, such as TableDDLOptions.Compartment
,
GetOptions.Compartment
, PutOptions.Compartment
, etc. Thus
you may also specify comparment separately for any operation. This value, if set, will override
the compartment value in NoSQLConfig
, if any.
If compartment is not supplied, the tenancy OCID will be used as default. Note this only applies if you are authorizing with user's identity. When using instance principal or resource principal, compartment id must be specified.
Related Topics
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website at http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc.
Access to Oracle Support
Oracle customers that have purchased support have access to electronic support through My Oracle Support. For information, visit http://www.oracle.com/pls/topic/lookup?ctx=acc&id=info or visit http://www.oracle.com/pls/topic/lookup?ctx=acc&id=trs if you are hearing impaired.