Skip to main content

ORDS.sql

I use this to display all ORDS settings that I need to know:

-- Run this part as dba user, until you see another comment about running as ORDS schema user

set echo on

set linesize 240

col object_type format a20

col object_name format a40

col proxy,client format a20

col parsing_schema format a20

col status format a10

col pre_hook format a10

col updated_by format a15

col created_by format a15

col auto_rest_auth format a10

COLUMN name FORMAT A60

COLUMN privilege_name FORMAT A60

COLUMN role_name FORMAT A50

COLUMN name FORMAT A40

COLUMN pattern FORMAT A40

COLUMN name FORMAT A20

col client_name format a20

COLUMN client_name FORMAT A30

COLUMN role_name FORMAT A20

set long 5000

column PARSING_SCHEMA format a20

col name format a60

COLUMN name FORMAT A40

COLUMN uri_prefix FORMAT A80

COLUMN uri_template FORMAT A20

COLUMN source_type FORMAT A30

COLUMN source FORMAT A60

col base_path format a30

col name format a40

col pattern format a20

col source format a20

col source_type format a40

col client_schema format a20

col role_schema  format a20

col schema format a20

-- display ORDS version

select * from ords_metadata.ords_version;

--list proxy users

col proxy format a40

col client format a40

select * from proxy_users where proxy='ORDS_PUBLIC_USER';

--display ORDS enabled schemas

--select * from DBA_ORDS_SCHEMAS;

--display url mapping pattern

--select * from DBA_ORDS_URL_MAPPINGS;

--display enabled schemas and their url mapping patterns

select s.*,m.pattern,type from DBA_ORDS_SCHEMAS s, DBA_ORDS_URL_MAPPINGS m where s.url_mapping_id=m.id;

COLUMN name FORMAT A60



--select distinct object_type,object_name from dba_objects where owner='ORDS_METADATA' and object_type in ('VIEW','TABLE') order by object_type,object_name;

-- view schema,client, role

select distinct client_id,(select parsing_schema from DBA_ORDS_SCHEMAS where id= cr.CLIENT_SCHEMA_ID) client_schema,client_name, role_id,role_name,(select parsing_schema from DBA_ORDS_SCHEMAS where id= cr.ROLE_SCHEMA_ID) role_schema 

from  ords_metadata.ORDS_CLIENT_ROLES cr;

-- view privs

select distinct (select parsing_schema from DBA_ORDS_SCHEMAS where id= m.SCHEMA_ID) schema, m.* from ords_metadata.ORDS_PRIVILEGE_MAPPINGS m;

-- view client privs

COLUMN client_priv_id FORMAT 999999 HEADING "Client Privilege ID"

COLUMN client_priv_created_by FORMAT A20 HEADING "Created By"

COLUMN client_priv_updated_by FORMAT A20 HEADING "Updated By"

COLUMN client_priv_client_id FORMAT 999999 HEADING "Client ID"

COLUMN priv_id FORMAT 999999 HEADING "Privilege ID"

COLUMN name FORMAT A20 HEADING "Name"

COLUMN label FORMAT A20 HEADING "Label"

COLUMN description FORMAT A30 HEADING "Description"

COLUMN parsing_schema FORMAT A15 HEADING "Parsing Schema"

COLUMN client_name FORMAT A15 HEADING "Client Name"

COLUMN client_created_by FORMAT A20 HEADING "Client Created By"

SELECT p.id client_priv_id,

  p.created_by client_priv_created_by,

  p.updated_by client_priv_updated_by,

  p.client_id client_priv_client_id,

  sec.id priv_id,

  sec.name,

  sec.label,

  sec.description,

  sch.parsing_schema,

  c.name client_name,

  c.created_by client_created_by

FROM ords_metadata.ords_schemas sch,

  ords_metadata.sec_privileges sec,

  ords_metadata.oauth_client_privileges p,

  ords_metadata.oauth_clients c

WHERE sch.id           = p.schema_id

AND sch.id             = c.schema_id

AND sec.id             = p.privilege_id

AND p.client_id        = c.id

;

-------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------

--part 1 : connect as ORDS user schema, and the following queries will display all ORDS settings of this schema, modules/templates/handlers etc

connect &ordsuser/&password@&connstring

set echo on

set linesize 240


--for ORDS settings

set echo on

set linesize 240

--view modules/template/handlers

COLUMN name FORMAT A50

COLUMN uri_prefix FORMAT A80

SELECT id, name, uri_prefix FROM   user_ords_modules ORDER BY name;

COLUMN uri_template FORMAT A20

col source format a60

SELECT id, module_id, uri_template FROM   user_ords_templates ORDER BY module_id;

SELECT id, template_id, source_type, method, source FROM   user_ords_handlers ORDER BY id;

-- display schema,modules||templates||handlers

COLUMN source_type FORMAT A30

COLUMN source FORMAT A60

COLUMN module_desc FORMAT A36 HEADING "Module Description"

COLUMN template_desc FORMAT A30 HEADING "Template Description"

COLUMN handler_desc FORMAT A30 HEADING "Handler Description"

COLUMN method FORMAT A10 HEADING "Method"

COLUMN source_type FORMAT A15 HEADING "Source Type"

COLUMN url FORMAT A50 HEADING "URL"

COLUMN parameter_count FORMAT 9999 HEADING "Parameter|Count"

COLUMN source FORMAT A50 HEADING "Source"

SELECT uoh.method,        uoh.source_type,        '<host_ref>' || uos.pattern || uom.uri_prefix || uot.uri_template url,        

(SELECT COUNT(id) FROM user_ords_parameters WHERE handler_id = uoh.id) parameter_count ,

uoh.source, uom.comments module_desc,        uot.comments template_desc,        uoh.comments handler_desc        

FROM user_ords_schemas   uos,      user_ords_modules   uom,      user_ords_templates uot,      user_ords_handlers  uoh

WHERE uot.module_id = uom.id AND uom.schema_id = uos.id AND uoh.template_id = uot.id 

--AND uos.parsing_schema = 'ORDSDEMO' 

ORDER BY uom.comments, uot.uri_template;

--display privs

col name format a40

SELECT id, name FROM   user_ords_privileges

--WHERE  name = 'emp_priv'

order by id;

--display privs and assigned roles

COLUMN privilege_name FORMAT A60

COLUMN role_name FORMAT A50


SELECT privilege_id, privilege_name, role_id, role_name FROM   user_ords_privilege_roles

--WHERE  role_name = 'emp_role'

;

--display privs and their mapping patterns

COLUMN priv_name FORMAT A40

COLUMN pattern FORMAT A40


SELECT privilege_id, name priv_name, pattern FROM   user_ords_privilege_mappings

--WHERE  name = 'emp_priv'

;

------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------

--Part 2 : display OAuth2 settings, clientid/secret/privs/roles/protected patterns

COLUMN name FORMAT A20


SELECT id, name, client_id, client_secret FROM  user_ords_clients;


--select name,CLIENT_ID,CLIENT_SECRET from ORDS_METADATA.OAUTH_CLIENTS;

-- Display client-privilege relationship.

col client_name format a20

SELECT name, client_name,CLIENT_PRIV_ID,PRIV_ID FROM   user_ords_client_privileges;


-- Display client-role relationship.

COLUMN client_name FORMAT A30

COLUMN role_name FORMAT A20


SELECT * from user_ords_client_roles;


-- view services

col base_path format a30

col name format a40

col pattern format a20

col source format a20

col source_type format a40

select method,base_path,pattern,name,module_id,template_id,handler_id,source_type,source from USER_ORDS_SERVICES;

-------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------

--part 3 : export ORDS settings for this ORDS enabled schemas


-- export schema, this will export all settings in this enabled schema

select ORDS_METADATA.ords_export.export_schema from dual;


set long 5000

set pagesize 1000

column PARSING_SCHEMA format a20

col name format a60

--display modules

select schema.parsing_schema,modules.name from user_ords_schemas schema, user_ORDS_MODULES modules where modules.schema_id=schema.id;

-- export modules: this will export all medules in this schema

select ORDS_METADATA.ords_export.export_module(p_module_name=>name) from user_ORDS_MODULES;


Comments

Popular posts from this blog

Opatch apply/lsinventory error: oneoff is corrupted or does not exist

I am applying the quarterly patch for 19c RDBMS, I tried using napply but failed, but somehow it corrupted the inventory though nothing applied. further apply and lsinventory command ran into error like this: $ ./OPatch/opatch lsinventory Oracle Interim Patch Installer version 12.2.0.1.21 Copyright (c) 2020, Oracle Corporation.  All rights reserved. Oracle Home       : /u02/app/oracle/19.0.0 Central Inventory : /u01/app/oraInventory    from           : /u02/app/oracle/19.0.0/oraInst.loc OPatch version    : 12.2.0.1.21 OUI version       : 12.2.0.7.0 Log file location : /u02/app/oracle/19.0.0/cfgtoollogs/opatch/opatch2020-09-08_13-35-59PM_1.log Lsinventory Output file location : /u02/app/oracle/19.0.0/cfgtoollogs/opatch/lsinv/lsinventory2020-09-08_13-35-59PM.txt -------------------------------------------------------------------------------- Inventory load failed... OPatch cannot load inventory ...

oracle dba_hist_sysmetric_summary

found this blog is helpful to get CPU and IO statistics on oracle database. http://shob-dbadmin.blogspot.ca/2012/12/how-to-find-total-io-of-database.html courtesy to  Shomil Bansal , below are hist writing, not mine. How to find total IO of the database instance Total IO of database instance is sum of the physical reads, physical writes and redo writes. There are several views to find these values. v$sysmetric  - Reports metric values for only the most current time sample 60 secs. v$sysmetric_summary  - Reports metric values for time sample of 1 hour. v$sysmetric_history  - Reports metric values every 60 sec from the time instance is up. Better way to analyse IO using this view to take deltas between two time periods. dba_hist_sysmetric_history  - All the above views are refreshed when the instance is restarted. This view, part of AWR, stores the historical stats. I have used this view for my report. Query: ====== set lines 350...

ORA_RMAN_SGA_TARGET

assume that we lost all the files of oracle database but we do have rman backup, when trying to bring up a dummy database before restore start, I get this error. RMAN> startup nomount force; WARNING: cannot translate ORA_RMAN_SGA_TARGET value startup failed: ORA-01078: failure in processing system parameters ORA-01565: error in identifying file '+DATA/PROD/spfilePROD.ora' ORA-17503: ksfdopn:2 Failed to open file +DATA/PROD/spfilePROD.ora ORA-15056: additional error message ORA-17503: ksfdopn:DGOpenFile05 Failed to open file +DATA/prod/spfileprod.ora ORA-17503: ksfdopn:2 Failed to open file +DATA/prod/spfileprod.ora ORA-15173: entry 'spfileprod.ora' does not exist in directory 'prod' ORA-06512: at line 4 starting Oracle instance without parameter file for retrival of spfile RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =================================...