I am working on a application which is used to get ddl of an Oracle database object.
Using following query to get objects of the database
SELECT object_name, object_type
FROM dba_objects
where owner = '" + alternative_schema + "'
order by object_type, object_name;
Using following query to get ddl of the db object
SELECT DBMS_METADATA.GET_DDL('TABLE','" + tableName + "','" + alternative_schema + "')
FROM dual;
and It is working fine.
To execute above queries oracle user need following grants
GRANT SELECT_CATALOG_ROLE TO john;
GRANT SELECT ANY TABLE TO john;
Now due to some security issue, dba is not allowing to grant SELECT_CATALOG_ROLE
and as my research says that with the SELECT_CATALOG_ROLE
its not possible.
But someone suggest to do it by 'sys'.
So now I can list of all objects by following query
select *
from sys.all_tables
where owner ='mydb'
Its returning all the created object under the mydb schema.
But my next challenge is to get ddl
How can I get ddl without having SELECT_CATALOG_ROLE
?
Is it possible by any way to execute DBMS_METADATA.GET_DDL without granting SELECT_CATALOG_ROLE
?
Update: according to the link oracle Security Model
Nonprivileged users can see the metadata of only their own objects.
So owner does not need to have "SELECT_CATALOG_ROLE"
permission to get_ddl()
and my user is readOnly type of user, I need to final solution to getDDL from readonly user (non-owner) account, which should not have SELECT_CATALOG_ROLE