SQL & PL/SQL :: Script To Find Out Objects Synonym And Privs
Jun 17, 2011
There are over 100 objects like tables,procedures,packages,triggers in my database.I am looking for a script/sql which should list out synonyms and grant privs on it.
Say i have a Procedure or package or any other stored subprogram, I need a script say to which i can pass this Procedure/Package/View etc name and then the code should give me the data results as which all other stored subprograms are used within the particular stored program name which we mentioned in our WHERE or Predicate clause
Is there a method or a tool out there that can do a search through an Oracle Schema to find objects ( tables, fields, stored procedures, etc) containing a specified character pattern ? For example : I would like to return all of the tables that contain fields containing the character string "ABC"
How can i identify all the occurences of raise_application_error(-20XXX, '<the message>'); within all database objects, and replace them with other text?
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Solaris: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
I have multiple schemas, all which have tons of objects that point to one column of one table. I tried to look at v$sqltext, and v$sqlarea, but it doesn't seem to show as expected.
Is there a view that I can look at that will show me all the objects that relate to one column?
my situation. Had to change the data structure of this one column. Changed the default value from a Y to an L. I have packages, functions, triggers...etc... that deal with this one column. I need to ensure that I go through EACH one and edit them to reflect the change to the table column. And again, this spans multiple schemas that point back to it.
We have two schemas which earlier used to be separate databases. There were DB links created to access the objects from one schema to the other schema when they were separate databases.
Since now they are just 2 separate schema with in the same Database, we would like to remove the DB Links and create synonyms to access those objects. These DB links were used in code in many places, it is becoming tough to find a way to implement this.
how to find all the objects that are using these objects or all the places these DB likns were being used.
I imported a schema HR from export DUMP ....i can find all the objects of schema HR in the imported database... but i got an error for a plan_table which is assigned to USERS tablespace in the source database.. ...
HERE COMES THE ERROR I GOT DURING IMPORT:
[oracle@localhost mom]$ imp file=exp_schema_ref.dmp log=imp.ref.log fromuser=hr touser=hr commit=y Import: Release 10.2.0.1.0 - Production on Mon Jul 26 00:03:57 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Username: sys/sys as sysdba
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via direct path import done in US7ASCII character set and AL16UTF16 NCHAR character set . importing HR's objects into HR . . importing table "COUNTRIES" 25 rows imported . . importing table "DEPARTMENTS" 27 rows imported . . importing table "EMPLOYEES" 107 rows imported [code]....
I am working on the roles and privs. I want to provide the privs on any object to any user through the roles. not a direct grant.I am having 150 users and 50 roles, I want to do this using the script is few strokes. for this I have tried to create a script but I am not able to make that.
For example There is 2 user scott and test
A. test is having select privs on scott.emp. B. Test is having insert,delete,update privs on scott.emp; c. DB is having 2 roles scott_edit - insert,delete,update privs on tables scott_read - select privs on tables
I want to revoke separate privs from test and want to given only scott_edit and scott_read (which(roles) is having all privs)
I have granted select privs on below tables to an exisiting user.grant select on WEB.ALMSTAT to nms...I would like to view the privs that i have granted to nms user?
*"In production, nms user will need the ability to read the following tables:*
I did an export using the following parfile (see below) I want to import all the objects associated with this schema into another DB but I want don't want to over-write any of the permissions such as grants.
Is there a way I can get the grants into a sql file before I do the import. If so, provide an example.
I'm making a function A that does many calls to procedures in an other package B. To make this function more readable, I'd like to specify synonyms for the procedures in B. I only need the synonyms inside this function, I don't want to make database synonyms.
For example:
Function get_all_employees return clob is v_emp clob; begin
I have exported and imported a schema from one server to another. In the source schema, I have a public synonym. I do not know the name of that synonym. In the destination schema, the public synonym is missing. How to create the public synonym which is missing in the destination database? In the source, I queried dba_synonyms, all_synonyms... but it returns no rows selected.
We are making Oracle Insight Application based on Oracle 11gR2 DB.We have two DEV environments. On Oct 17, we had trouble in one DEV environment.From dba_common_audit_trail , we found some user did drop public synonym statement and we doubt it as cause of the problem. I would like to collect synonym information of the two DEV environment.1How could I do that ?2And we are thinking of using Logminer to investigate the cause of problem.Logminer is usable to investigate the cause of problem if we have the REDO log of Oct 17 ?
Now I have another db where I wish to import the above dump. This is not a empty db, however, I have dropped the particular user from this db for which I have created a dump above. Then I have created the same user using 'create user....'.And now I am trying to import the above dump into this.
import goes fine but I gets the circular synonym error for some of the types.
IMP-00003: ORACLE error 4055 encountered ORA-04055: Aborted: "O_BULK_TARGET_SELECTOR" formed a non-REF mutually-dependent cycle with "T_GENERAL_IDLIST". ORA-06550: line 5, column 25: PLS-00421: circular synonym 'PUBLIC.T_GENERAL_IDLIST'
The db from which I created the dmp has no errors for these objects, but while impoting it gives these errors.I have even tried taking the whole database dmp(not a particular user), and importing it into full empty database. Then also I gets the same error.
I have schema a and b in the same database with synonym table a (schema a) to schema b. When I try to disable trigger from table a in schema b; I got this message:
ORA-00942: table or view does not exist
I have granted all permissions to schema b and I am able to SELECT FROM table a in schema b
How can I create a trigger to check if synonym already exists in db and if exists then don't create synonym.
my work: ( this is just like an outline i prepared)
select * from all_synonyms; declare s_exists number; begin -- check whether the synonym exists select 1 into s_exists from all_synonyms; -- an error gets raise if it doesn't exception when no_data_found then -- DDL has to be done inside execute immediate ' create or replace synonym'; end; /
I've got to collect statistics by DBMS_STAT. For the first time, the spcreate.sql is to be called, however, it returned one error following:
If this script is automatically called from spcreate (which is the supported method), all STATSPACK segments will be created in the PERFSTAT user's default tablespace.
Using perfstat tablespace to store Statspack objects
create public synonym STATS$SNAPSHOT_ID for STATS$SNAPSHOT_ID * ERROR at line 1: ORA-00955: name is already used by an existing object Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options
And then, I checked it again with its owner:
SQL> select owner, synonym_name 2 from dba_synonyms 3 where synonym_name='STATS$SNAPSHOT_ID';
OWNER SYNONYM_NAME ------------------------------ ------------------------------ PUBLIC STATS$SNAPSHOT_ID
Then, I checked again after dropping schema PERFSTAT:
I have exported and imported a schema from one server to another. In the source schema, I have a public synonym. I do not know the name of that synonym. In the destination schema, the public synonym is missing. How to create the public synonym which is missing in the destination database?In the source, I queried dba_synonyms, all_synonyms... but it returns no rows selected.
from sysdba i grant to my user hospital creat any synonym but give me this error why ?
SQL> conn sys as sysdba Enter password: Connected. SQL> grant create any synonym to hospital 2 ;
Grant succeeded.
SQL> conn hospital Enter password: Connected. SQL> create public synonym Sur 2 for surgeries; create public synonym Sur * ERROR at line 1: ORA-01031: insufficient privileges
But what I noticed is that user HIEL has a connect role but YONC does not. (Result set is below) Have searched for information but did not find what I was looking for. I did read something about backward compatibility.I'm leaning towards that thought since the other user YONC does not have this role.
Database: 11g R1
SQL> select * from dba_role_privs where grantee in ('YONC', 'HIEL') order by grantee; GRANTEE GRANTED_ROLE ADM DEF --------------------------- --------------------------- --- --- YONC WCAIMS_INQUIRY NO YES YONC ENDUSER NO YES HIEL WCAIMS_CSR_ADDR NO YES
we are facing an issue with the dbms scheduler jobs, which is not processing the synonym which is created via dblink from anthoer schema.
Let me explain the situation.
Table in Schema :APP_COMMON DB: APPL -------------------------------------
CREATE TABLE TEST_LOG (A VARCHAR2(10));
INSERT TEST_LOG VALUES ('TESTED');
GRANT SELECT ON TEST_LOG to APP_GEN ;
Table in Schema :APP_GEN DB: APPL -------------------------------------
CREATE SYNONYM TEST_LOG FOR APP_COMMON.TEST_LOG;
SELECT * from TEST_LOG;
-- it returns the value
Table in Schema :APP_GEN DB: REPORT -------------------------------------
This is the different DB (we have 2 DB's, one for report db and one for application DB). here we create the DB link (connected DB menthod) . Since we have the password sync between the databases, we create the DBLINK without user id and password.
CREATE DATABASE LINK "APPL_LINK" USING 'APPL' ;
CREATE SYNONYM TEST_LOG FOR TEST_LOG@APPL_LINK;
SELECT * from TEST_LOG; --it returns the value.
Now in the same DB, we have a scheduler which will run for every min.
Now Scheduler is not selecting this table. Rather not processing the synonym(TEST_LOG). Not able to capture the exception also.
I have one schema argus_app where there is a table cfg_enterprise. There is a view v$cfg_enterprisewhich selects data from cfg_enterprise and there is apublic synonym cfg_enterprise for v$cfg_enterprise.
When I login to argus_app and select from cfg_enterprise there is no data where as i log in to sys and select I can see data.
SQL> conn /as sysdba Connected. SQL> select enterprise_name from cfg_enterprise;
Ive created a scenario to what im trying to achieve here so ignore how its set-up attribute wise.
CREATE TYPE object_obj AS OBJECT ( obj_id NUMBER, NAME VARCHAR2(20), age NUMBER) NOT FINAL; /
CREATE TYPE object_ext UNDER object_obj ( course_name VARCHAR2(20));
/ CREATE TYPE object_ext2 UNDER object_obj ( location VARCHAR2(20); /
CREATE TABLE object_tab OF object_obj(obj_id PRIMARY KEY); /
Now for the course_name i need to make sure it can only be on of these three values ('Science','Math','English'). I can't find a way to apply this constraint without making a table. But then that creates another issue of how to insert the data from the main supertype (object_obj) and i only want the object_tab table and view the subtypes via a select query.