DBA Hub

📋Steps in this guide1/12

Oracle REST Data Services (ORDS) : Database API - PDB Lifecyle Management

The Oracle REST Data Services (ORDS) database API allows us to manage the lifecycle of PDBs via REST web service calls.

oracle miscconfigurationintermediate
by OracleDba
17 views
1

Assumptions

This article assumes the following.
2

Enable ORDS Database API (ORDS Version 22.1 Onward)

If you have followed one of the ORDS installation articles from on this site, you may already have the ORDS Database API enabled. During the installation the following command line arguments can be used to enable REST Enabled SQL and the ORDS Database API. For an existing installation, the following commands will set these attributes. Remember to restart ORDS after altering the settings. We are using Tomcat to run ORDS, so we would restart Tomcat to restart ORDS. If you are running ORDS in standalone mode, you will then need to restart ORDS, as described here . There is an additional level of control using the parameter, which is set to by default. Setting this to during the installation, or using the above command syntax will disable the following services. - DBCA Jobs - DBCA Templates - Oracle Home Environment - PDB Lifecycle - Open Service Broker

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
--feature-rest-enabled-sql true
--feature-db-api true

export ORDS_HOME=/u01/ords
export ORDS_CONFIG=/u01/config/ords
export PATH=${ORDS_HOME}/bin:${PATH}

ords --config ${ORDS_CONFIG} config set restEnabledSql.active true
ords --config ${ORDS_CONFIG} config set database.api.enabled true

$CATALINA_HOME/bin/shutdown.sh
$CATALINA_HOME/bin/startup.sh
3

Enable ORDS Database API (ORDS Versions 21.4 or lower)

If you have followed one of the ORDS installation articles from on this site, you may already have the ORDS Database API enabled. During the installation the following properties can be included in the properties file to enable REST Enabled SQL and the ORDS Database API. For an existing installation, the following commands will set these properties in the "defaults.xml" file. Remember to restart ORDS after altering the settings. We are using Tomcat to run ORDS, so we would restart Tomcat to restart ORDS. If you are running ORDS in standalone mode, you will then need to restart ORDS, as described here . There is an additional level of control using the parameter, which is set to by default. Setting this to during the installation, or using the above command syntax will disable the following services. - DBCA Jobs - DBCA Templates - Oracle Home Environment - PDB Lifecycle - Open Service Broker

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
restEnabledSql.active=true
database.api.enabled=true

cd /u01/ords
$JAVA_HOME/bin/java -jar ords.war set-property restEnabledSql.active true
$JAVA_HOME/bin/java -jar ords.war set-property database.api.enabled true

$CATALINA_HOME/bin/shutdown.sh
$CATALINA_HOME/bin/startup.sh
4

Database Credentials : PDB Lifecycle Management

For the PDB Lifecycle Management functionality to work we need an ORDS installations in the root container of a Multitenant installation. It will not work if you install ORDS in the PDB. For the PDB Lifecycle Management services we need a user in the root container with privileges. We need to add these credentials to the ORDS connection pool. For the default connection pool we would do something like the following. We add the credential parameters to a properties file, set the properties for the connection pool, then delete the properties file. Remember to restart ORDS after altering the settings.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
conn / as sysdba
create user c##pdb_lifecycle_user identified by PdbLifecycleUserPassword1;
grant create session to c##pdb_lifecycle_user container=all;
grant sysdba to c##pdb_lifecycle_user container=all;

cat > /tmp/pdb_lifecycle_user.properties <<EOF
db.cdb.adminUser=c##pdb_lifecycle_user as sysdba
db.cdb.adminUser.password=PdbLifecycleUserPassword1
EOF

cd /u01/ords
$JAVA_HOME/bin/java -jar ords.war set-properties --conf apex_pu /tmp/pdb_lifecycle_user.properties
rm /tmp/pdb_lifecycle_user.properties
5

Application Server Credentials

We need application server credentials mapped to the "SQL Administrator" role to allow us to authenticate to the PDB Lifecycle Management REST endpoints. How you achieve this will vary depending on the way you are running ORDS. If you are running ORDS under Tomcat, you must add the relevant credentials to the "$CATALINA_BASE/conf/tomcat-users.xml" file. The example below create a new "SQL Administrator" role and maps a user to that role. You must then restart Tomcat. If you are running in standalone mode, you may wish to use the file-based repository. You can create a similar user using the following command, which will prompt for a password. You will then need to restart ORDS, as described here .

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
<role rolename="SQL Administrator"/>
  <user username="sql_admin" password="sql_admin_password1" roles="SQL Administrator"/>

$CATALINA_HOME/bin/shutdown.sh
$CATALINA_HOME/bin/startup.sh

cd /u01/ords
$JAVA_HOME/bin/java -jar ords.war user sql_admin "SQL Administrator"
6

Basic Usage

The PDB Lifecycle Management REST endpoints are described here . The examples below use the utility to give an idea of their basic usage. The examples include a few common elements. - : We are using a self-signed certificate, which sees as weak. The "-k" options tells to ignore the weak certificate. This is not necessary if you are using a certificate from a certificate authority. - : Run in silent mode, to remove additional output. - : Define the HTTP method used for the call. These will typically be , , , , but there are others. - : Enter the application server credentials defined earlier. - : The JSON output is minified, which is hard to read. This Python utility reformats the JSON to make is more readable. You would not use this for real calls. - : We use this option to pass a JSON document as a raw payload. This can be inline, or from a file using the "@" symbol. - : The POST and DELETE HTTP methods require the Content-Type header to be included.
7

Get All PDBs

We list all pluggable databases in the CDB using a HTTP GET method call to the "_/db-api/stable/database/pdbs/" endpoint.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
curl -ks -X GET \
  --user sql_admin:sql_admin_password1 \
  https://localhost:8443/ords/
_/db-api/stable/database/pdbs/
| python3 -mjson.tool
{
    "items": [
        {
            "inst_id": 1,
            "con_id": 2,
            "dbid": 1559324454,
            "con_uid": 1559324454,
            "guid": "rxFYwrB1TODgVQAAAAAAAQ==",
            "name": "PDB$SEED",
            "open_mode": "READ ONLY",
            "restricted": "NO",
            "open_time": "2020-09-27T08:56:25.613Z",
            "create_scn": 2140470,
            "total_size": 944766976,
            "block_size": 8192,
            "recovery_status": "ENABLED",
            "snapshot_parent_con_id": null,
            "application_root": "NO",
            "application_pdb": "NO",
            "application_seed": "NO",
            "application_root_con_id": null,
            "application_root_clone": "NO",
            "proxy_pdb": "NO",
            "local_undo": 1,
            "undo_scn": 280,
            "undo_timestamp": null,
            "creation_time": "2020-09-11T21:27:07Z",
            "diagnostics_size": 0,
            "pdb_count": 0,
            "audit_files_size": 0,
            "max_size": 0,
            "max_diagnostics_size": 0,
            "max_audit_size": 0,
            "last_changed_by": "COMMON USER",
            "template": "NO",
            "tenant_id": null,
            "upgrade_level": 1,
            "guid_base64": "rxFYwrB1TODgVQAAAAAAAQA=",
            "links": [
                {
                    "rel": "self",
                    "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/PDB%24SEED/"
                }
            ]
        },
        {
            "inst_id": 1,
            "con_id": 3,
            "dbid": 2277034905,
            "con_uid": 2277034905,
            "guid": "rxGDVQlLUpzgVQAAAAAAAQ==",
            "name": "PDB1",
            "open_mode": "READ WRITE",
            "restricted": "NO",
            "open_time": "2020-09-27T10:40:18.344Z",
            "create_scn": 2395196,
            "total_size": 9426698240,
            "block_size": 8192,
            "recovery_status": "ENABLED",
            "snapshot_parent_con_id": null,
            "application_root": "NO",
            "application_pdb": "NO",
            "application_seed": "NO",
            "application_root_con_id": null,
            "application_root_clone": "NO",
            "proxy_pdb": "NO",
            "local_undo": 1,
            "undo_scn": 280,
            "undo_timestamp": null,
            "creation_time": "2020-09-11T21:39:01Z",
            "diagnostics_size": 0,
            "pdb_count": 0,
            "audit_files_size": 0,
            "max_size": 0,
            "max_diagnostics_size": 0,
            "max_audit_size": 0,
            "last_changed_by": "COMMON USER",
            "template": "NO",
            "tenant_id": null,
            "upgrade_level": 1,
            "guid_base64": "rxGDVQlLUpzgVQAAAAAAAQA=",
            "links": [
                {
                    "rel": "self",
                    "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/PDB1/"
                }
            ]
        },
        {
            "inst_id": 1,
            "con_id": 4,
            "dbid": 3289938731,
            "con_uid": 3289938731,
            "guid": "r5Oz/RdPIPLgVQAAAAAAAQ==",
            "name": "PDB2",
            "open_mode": "READ WRITE",
            "restricted": "NO",
            "open_time": "2020-09-27T08:56:28.790Z",
            "create_scn": 3955989,
            "total_size": 986710016,
            "block_size": 8192,
            "recovery_status": "ENABLED",
            "snapshot_parent_con_id": null,
            "application_root": "NO",
            "application_pdb": "NO",
            "application_seed": "NO",
            "application_root_con_id": null,
            "application_root_clone": "NO",
            "proxy_pdb": "NO",
            "local_undo": 1,
            "undo_scn": 280,
            "undo_timestamp": null,
            "creation_time": "2020-09-18T08:58:23Z",
            "diagnostics_size": 0,
            "pdb_count": 0,
            "audit_files_size": 0,
            "max_size": 0,
            "max_diagnostics_size": 0,
            "max_audit_size": 0,
            "last_changed_by": "COMMON USER",
            "template": "NO",
            "tenant_id": null,
            "upgrade_level": 1,
            "guid_base64": "r5Oz/RdPIPLgVQAAAAAAAQA=",
            "links": [
                {
                    "rel": "self",
                    "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/PDB2/"
                }
            ]
        }
    ],
    "hasMore": false,
    "limit": 25,
    "offset": 0,
    "count": 3,
    "links": [
        {
            "rel": "self",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/"
        },
        {
            "rel": "describedby",
            "href": "https://localhost:8443/ords/_/db-api/stable/metadata-catalog/"
        },
        {
            "rel": "first",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/"
        }
    ]
}
8

Get a PDB

We list details about a specific pluggable database in the CDB using a HTTP GET method call to the "_/db-api/stable/database/pdbs/{pdb-name}/" endpoint. The details include the datafiles.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
curl -ks  -X GET \
     --user sql_admin:sql_admin_password1 \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/pdb1/
| python3 -mjson.tool
{
    "inst_id": 1,
    "con_id": 3,
    "dbid": 2277034905,
    "con_uid": 2277034905,
    "guid": "rxGDVQlLUpzgVQAAAAAAAQ==",
    "name": "PDB1",
    "open_mode": "READ WRITE",
    "restricted": "NO",
    "open_time": "2020-09-27T10:40:18.344Z",
    "create_scn": 2395196,
    "total_size": 9426698240,
    "block_size": 8192,
    "recovery_status": "ENABLED",
    "snapshot_parent_con_id": null,
    "application_root": "NO",
    "application_pdb": "NO",
    "application_seed": "NO",
    "application_root_con_id": null,
    "application_root_clone": "NO",
    "proxy_pdb": "NO",
    "local_undo": 1,
    "undo_scn": 280,
    "undo_timestamp": null,
    "creation_time": "2020-09-11T21:39:01Z",
    "diagnostics_size": 0,
    "pdb_count": 0,
    "audit_files_size": 0,
    "max_size": 0,
    "max_diagnostics_size": 0,
    "max_audit_size": 0,
    "last_changed_by": "COMMON USER",
    "template": "NO",
    "tenant_id": null,
    "upgrade_level": 1,
    "guid_base64": "rxGDVQlLUpzgVQAAAAAAAQA=",
    "data_files": [
        {
            "inst_id": 1,
            "file#": 9,
            "creation_change#": 2395196,
            "creation_time": "2020-09-11T21:39:06Z",
            "ts#": 0,
            "rfile#": 1,
            "status": "SYSTEM",
            "enabled": "READ WRITE",
            "checkpoint_change#": 4579704,
            "checkpoint_time": "2020-09-27T13:00:34Z",
            "unrecoverable_change#": 0,
            "unrecoverable_time": null,
            "last_change#": null,
            "last_time": null,
            "offline_change#": 4537177,
            "online_change#": 4537221,
            "online_time": "2020-09-27T10:40:18Z",
            "bytes": 440401920,
            "blocks": 53760,
            "create_bytes": 314572800,
            "block_size": 8192,
            "name": "/u02/oradata/CDB1/pdb1/system01.dbf",
            "plugged_in": 0,
            "block1_offset": 8192,
            "aux_name": "NONE",
            "first_nonlogged_scn": 0,
            "first_nonlogged_time": null,
            "foreign_dbid": 0,
            "foreign_creation_change#": 0,
            "foreign_creation_time": null,
            "plugged_readonly": "NO",
            "plugin_change#": 0,
            "plugin_resetlogs_change#": 0,
            "plugin_resetlogs_time": null,
            "con_id": 3
        },
        {
            "inst_id": 1,
            "file#": 10,
            "creation_change#": 2395204,
            "creation_time": "2020-09-11T21:39:06Z",
            "ts#": 1,
            "rfile#": 4,
            "status": "ONLINE",
            "enabled": "READ WRITE",
            "checkpoint_change#": 4579704,
            "checkpoint_time": "2020-09-27T13:00:34Z",
            "unrecoverable_change#": 0,
            "unrecoverable_time": null,
            "last_change#": null,
            "last_time": null,
            "offline_change#": 4537177,
            "online_change#": 4537221,
            "online_time": "2020-09-27T10:40:18Z",
            "bytes": 471859200,
            "blocks": 57600,
            "create_bytes": 419430400,
            "block_size": 8192,
            "name": "/u02/oradata/CDB1/pdb1/sysaux01.dbf",
            "plugged_in": 0,
            "block1_offset": 8192,
            "aux_name": "NONE",
            "first_nonlogged_scn": 0,
            "first_nonlogged_time": null,
            "foreign_dbid": 0,
            "foreign_creation_change#": 0,
            "foreign_creation_time": null,
            "plugged_readonly": "NO",
            "plugin_change#": 0,
            "plugin_resetlogs_change#": 0,
            "plugin_resetlogs_time": null,
            "con_id": 3
        },
        {
            "inst_id": 1,
            "file#": 11,
            "creation_change#": 2395222,
            "creation_time": "2020-09-11T21:39:06Z",
            "ts#": 2,
            "rfile#": 9,
            "status": "ONLINE",
            "enabled": "READ WRITE",
            "checkpoint_change#": 4579704,
            "checkpoint_time": "2020-09-27T13:00:34Z",
            "unrecoverable_change#": 0,
            "unrecoverable_time": null,
            "last_change#": null,
            "last_time": null,
            "offline_change#": 4537177,
            "online_change#": 4537221,
            "online_time": "2020-09-27T10:40:18Z",
            "bytes": 613416960,
            "blocks": 74880,
            "create_bytes": 173015040,
            "block_size": 8192,
            "name": "/u02/oradata/CDB1/pdb1/undotbs01.dbf",
            "plugged_in": 0,
            "block1_offset": 8192,
            "aux_name": "NONE",
            "first_nonlogged_scn": 0,
            "first_nonlogged_time": null,
            "foreign_dbid": 0,
            "foreign_creation_change#": 0,
            "foreign_creation_time": null,
            "plugged_readonly": "NO",
            "plugin_change#": 0,
            "plugin_resetlogs_change#": 0,
            "plugin_resetlogs_time": null,
            "con_id": 3
        },
        {
            "inst_id": 1,
            "file#": 12,
            "creation_change#": 2397411,
            "creation_time": "2020-09-11T21:39:13Z",
            "ts#": 5,
            "rfile#": 12,
            "status": "ONLINE",
            "enabled": "READ WRITE",
            "checkpoint_change#": 4579704,
            "checkpoint_time": "2020-09-27T13:00:34Z",
            "unrecoverable_change#": 0,
            "unrecoverable_time": null,
            "last_change#": null,
            "last_time": null,
            "offline_change#": 4537177,
            "online_change#": 4537221,
            "online_time": "2020-09-27T10:40:18Z",
            "bytes": 5242880,
            "blocks": 640,
            "create_bytes": 5242880,
            "block_size": 8192,
            "name": "/u02/oradata/CDB1/pdb1/users01.dbf",
            "plugged_in": 0,
            "block1_offset": 8192,
            "aux_name": "NONE",
            "first_nonlogged_scn": 0,
            "first_nonlogged_time": null,
            "foreign_dbid": 0,
            "foreign_creation_change#": 0,
            "foreign_creation_time": null,
            "plugged_readonly": "NO",
            "plugin_change#": 0,
            "plugin_resetlogs_change#": 0,
            "plugin_resetlogs_time": null,
            "con_id": 3
        },
        {
            "inst_id": 1,
            "file#": 13,
            "creation_change#": 2397490,
            "creation_time": "2020-09-11T21:39:18Z",
            "ts#": 6,
            "rfile#": 13,
            "status": "ONLINE",
            "enabled": "READ WRITE",
            "checkpoint_change#": 4579704,
            "checkpoint_time": "2020-09-27T13:00:34Z",
            "unrecoverable_change#": 0,
            "unrecoverable_time": null,
            "last_change#": null,
            "last_time": null,
            "offline_change#": 4537177,
            "online_change#": 4537221,
            "online_time": "2020-09-27T10:40:18Z",
            "bytes": 247463936,
            "blocks": 30208,
            "create_bytes": 1048576,
            "block_size": 8192,
            "name": "/u02/oradata/CDB1/AF118355094B529CE055000000000001/datafile/o1_mf_apex_hoqvn6v1_.dbf",
            "plugged_in": 0,
            "block1_offset": 8192,
            "aux_name": "NONE",
            "first_nonlogged_scn": 0,
            "first_nonlogged_time": null,
            "foreign_dbid": 0,
            "foreign_creation_change#": 0,
            "foreign_creation_time": null,
            "plugged_readonly": "NO",
            "plugin_change#": 0,
            "plugin_resetlogs_change#": 0,
            "plugin_resetlogs_time": null,
            "con_id": 3
        },
        {
            "inst_id": 1,
            "file#": 14,
            "creation_change#": 2817107,
            "creation_time": "2020-09-13T15:31:20Z",
            "ts#": 7,
            "rfile#": 1024,
            "status": "ONLINE",
            "enabled": "READ WRITE",
            "checkpoint_change#": 4579704,
            "checkpoint_time": "2020-09-27T13:00:34Z",
            "unrecoverable_change#": 0,
            "unrecoverable_time": null,
            "last_change#": null,
            "last_time": null,
            "offline_change#": 4537177,
            "online_change#": 4537221,
            "online_time": "2020-09-27T10:40:18Z",
            "bytes": 2704277504,
            "blocks": 330112,
            "create_bytes": 2469396480,
            "block_size": 8192,
            "name": "/u02/oradata/CDB1/AF118355094B529CE055000000000001/datafile/o1_mf_soe_howgswlc_.dbf",
            "plugged_in": 0,
            "block1_offset": 8192,
            "aux_name": "NONE",
            "first_nonlogged_scn": 0,
            "first_nonlogged_time": null,
            "foreign_dbid": 0,
            "foreign_creation_change#": 0,
            "foreign_creation_time": null,
            "plugged_readonly": "NO",
            "plugin_change#": 0,
            "plugin_resetlogs_change#": 0,
            "plugin_resetlogs_time": null,
            "con_id": 3
        },
        {
            "inst_id": 1,
            "file#": 15,
            "creation_change#": 3894810,
            "creation_time": "2020-09-13T16:03:03Z",
            "ts#": 8,
            "rfile#": 1024,
            "status": "ONLINE",
            "enabled": "READ WRITE",
            "checkpoint_change#": 4579704,
            "checkpoint_time": "2020-09-27T13:00:34Z",
            "unrecoverable_change#": 0,
            "unrecoverable_time": null,
            "last_change#": null,
            "last_time": null,
            "offline_change#": 4537177,
            "online_change#": 4537221,
            "online_time": "2020-09-27T10:40:18Z",
            "bytes": 1677721600,
            "blocks": 204800,
            "create_bytes": 1073741824,
            "block_size": 8192,
            "name": "/u02/oradata/CDB1/AF118355094B529CE055000000000001/datafile/o1_mf_tpcdslik_howjom19_.dbf",
            "plugged_in": 0,
            "block1_offset": 8192,
            "aux_name": "NONE",
            "first_nonlogged_scn": 0,
            "first_nonlogged_time": null,
            "foreign_dbid": 0,
            "foreign_creation_change#": 0,
            "foreign_creation_time": null,
            "plugged_readonly": "NO",
            "plugin_change#": 0,
            "plugin_resetlogs_change#": 0,
            "plugin_resetlogs_time": null,
            "con_id": 3
        },
        {
            "inst_id": 1,
            "file#": 16,
            "creation_change#": 3894875,
            "creation_time": "2020-09-13T16:03:06Z",
            "ts#": 9,
            "rfile#": 1024,
            "status": "ONLINE",
            "enabled": "READ WRITE",
            "checkpoint_change#": 4579704,
            "checkpoint_time": "2020-09-27T13:00:34Z",
            "unrecoverable_change#": 0,
            "unrecoverable_time": null,
            "last_change#": null,
            "last_time": null,
            "offline_change#": 4537177,
            "online_change#": 4537221,
            "online_time": "2020-09-27T10:40:18Z",
            "bytes": 1479540736,
            "blocks": 180608,
            "create_bytes": 472907776,
            "block_size": 8192,
            "name": "/u02/oradata/CDB1/AF118355094B529CE055000000000001/datafile/o1_mf_tpcdslik_howjorxn_.dbf",
            "plugged_in": 0,
            "block1_offset": 8192,
            "aux_name": "NONE",
            "first_nonlogged_scn": 0,
            "first_nonlogged_time": null,
            "foreign_dbid": 0,
            "foreign_creation_change#": 0,
            "foreign_creation_time": null,
            "plugged_readonly": "NO",
            "plugin_change#": 0,
            "plugin_resetlogs_change#": 0,
            "plugin_resetlogs_time": null,
            "con_id": 3
        }
    ],
    "links": [
        {
            "rel": "self",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/pdb1/"
        },
        {
            "rel": "describedby",
            "href": "https://localhost:8443/ords/_/db-api/stable/metadata-catalog/"
        },
        {
            "rel": "collection",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/"
        },
        {
            "rel": "status",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/pdb1/status"
        }
    ]
}
9

Get the Status of a PDB

We get the status of a specific pluggable database in the CDB using a HTTP GET method call to the "_/db-api/stable/database/pdbs/{pdb-name}/status" endpoint.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
curl -ks -X GET \
     --user sql_admin:sql_admin_password1 \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/pdb1/status
| python3 -mjson.tool
{
    "inst_id": 1,
    "con_id": 3,
    "name": "PDB1",
"open_mode": "READ WRITE"
,
    "restricted": "NO",
    "links": [
        {
            "rel": "collection",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/pdb1/"
        }
    ]
}
10

Change the Status of a PDB

We change the status of a specific pluggable database in the CDB using a HTTP POST method call to the "_/db-api/stable/database/pdbs/{pdb-name}/" endpoint. We need a JSON payload describing the status change. We then make the POST call for the PDB1 pluggable database passing the payload. We check the status of the PDB1 pluggable database. We create a new JSON payload to change the status of the PDB1 pluggable database back. We make the call again, passing the new payload. We check the status of the PBD1 pluggable database.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
cat > /tmp/payload.json <<EOF
{
  "state": "CLOSE",
  "modifyOption": "IMMEDIATE"
}
EOF

curl -ks -X POST \
     --user sql_admin:sql_admin_password1 \
     --data-binary @/tmp/payload.json \
     --header "Content-Type:application/json" \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/pdb1/status
| python3 -mjson.tool
{
    "env": {
        "defaultTimeZone": "UTC"
    },
    "items": [
        {
            "statementId": 1,
            "response": [
                "\nPluggable database \"pdb1\" altered.\n\n"
            ],
            "result": 0
        }
    ]
}

curl -ks -X GET \
     --user sql_admin:sql_admin_password1 \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/pdb1/status
| python3 -mjson.tool
{
    "inst_id": 1,
    "con_id": 3,
    "name": "PDB1",
"open_mode": "MOUNTED"
,
    "restricted": null,
    "links": [
        {
            "rel": "collection",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/pdb1/"
        }
    ]
}

cat > /tmp/payload.json <<EOF
{
  "state": "OPEN",
  "modifyOption": "NORMAL"
}
EOF

curl -ks -X POST \
     --user sql_admin:sql_admin_password1 \
     --data-binary @/tmp/payload.json \
     --header "Content-Type:application/json" \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/pdb1/status
| python3 -mjson.tool
{
    "env": {
        "defaultTimeZone": "UTC"
    },
    "items": [
        {
            "statementId": 1,
            "response": [
                "\nPluggable database \"pdb1\" altered.\n\n"
            ],
            "result": 0
        }
    ]
}

curl -ks -X GET \
     --user sql_admin:sql_admin_password1 \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/pdb1/status
| python3 -mjson.tool
{
    "inst_id": 1,
    "con_id": 3,
    "name": "PDB1",
"open_mode": "READ WRITE"
,
    "restricted": "NO",
    "links": [
        {
            "rel": "collection",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/pdb1/"
        }
    ]
}
11

Create a PDB

We create a new PDB from the seed database using a HTTP POST method call to the "_/db-api/stable/database/pdbs/" endpoint. The payload describes the action we want to perform. In this case we are creating a new pluggable database called PDB3. We are using Oracle Managed Files (OMF), so we don't need to include file name conversions. We make the post call, passing the JSON payload. We check the status of the new PDB3 pluggable database.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
cat > /tmp/payload.json <<EOF
{
  "method": "CREATE",
  "pdb_name": "pdb3",
  "adminName": "pdbadmin",
  "adminPwd": "MyPassword1",
  "fileNameConversions": "NONE",
  "unlimitedStorage": true,
  "reuseTempFile": true,
  "totalSize": "UNLIMITED",
  "tempSize": "UNLIMITED"
}
EOF

curl -ks -X POST \
     --user sql_admin:sql_admin_password1 \
     --data-binary @/tmp/payload.json \
     --header "Content-Type:application/json" \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/
| python3 -mjson.tool
{
    "env": {
        "defaultTimeZone": "UTC"
    },
    "items": [
        {
            "statementId": 1,
            "response": [
                "\nPL/SQL procedure successfully completed.\n\n"
            ],
            "result": 0
        },
        {
            "statementId": 2,
            "response": [
                "\nPluggable database \"pdb3\" altered.\n\n"
            ],
            "result": 0
        },
        {
            "statementId": 3,
            "response": [],
            "result": 0
        }
    ]
}

curl -ks -X GET \
     --user sql_admin:sql_admin_password1 \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/pdb3/status
| python3 -mjson.tool
{
    "inst_id": 1,
    "con_id": 5,
    "name": "PDB3",
    "open_mode": "READ WRITE",
    "restricted": "NO",
    "links": [
        {
            "rel": "collection",
            "href": "https://localhost:8443/ords/_/db-api/stable/database/pdbs/pdb3/"
        }
    ]
}
12

Drop a PDB

We drop a specific pluggable database in the CDB using a HTTP DELETE method call to the "_/db-api/stable/database/pdbs/{pdb-name}/" endpoint. We create a payload describing the action. By default the drop will attempt to keep the datafiles. We use an action of to make sure the datafiles are dropped. We now make the call passing the payload. For more information see: - Enabling ORDS Database API - About the REST APIs - Pluggable Database Lifecycle Management REST Endpoints - Oracle REST Data Services (ORDS) : Database API - Database Administration - Oracle REST Data Services (ORDS) : All Articles Hope this helps. Regards Tim...

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
cat > /tmp/payload.json <<EOF
{
  "action": "INCLUDING"
}
EOF

curl -ks -X DELETE \
     --user sql_admin:sql_admin_password1 \
     --data-binary @/tmp/payload.json \
     --header "Content-Type:application/json" \
     https://localhost:8443/ords/
_/db-api/stable/database/pdbs/pdb3/
| python3 -mjson.tool
{
    "env": {
        "defaultTimeZone": "UTC"
    },
    "items": [
        {
            "statementId": 1,
            "response": [
                "\nPL/SQL procedure successfully completed.\n\n"
            ],
            "result": 0
        }
    ]
}

Comments (0)

Please to add comments

No comments yet. Be the first to comment!