ORA-01435: user does not exist when accessing V$Locked_Object in Oracle - oracle

I am trying to run below query from SOME_USER
SELECT * FROM V$Locked_Object; -- Public Synonym
also tried
SELECT * FROM "SYS"."V_$LOCKED_OBJECT";
and getting.
ORA-01435: user does not exist
01435. 00000 - "user does not exist"
*Cause:
*Action:
I have given these grants from SYS to SOME_USER
grant select on "SYS"."V_$LOCKED_OBJECT" to SOME_USER; still getting the same error.
I noticed that I am able to access other public synonyms in SOME_USER like V$LOCK_ACTIVITY, v$lock_type etc. getting this error when trying V$Locked_Object and V$LOCK only. Please suggest maybe I am missing some basics.
Oracle Version - Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

I'd suggest you to check against metadata.
First, check whether the object exists in the DB at all (I'm sure it exists, but still for double checking).
I hope you have access to dba_% objects
select * from dba_objects where object_name like 'V%LOCKED%OBJ%';
Then, check if you have the permissions to access that object
select * from all_objects where object_name like 'V%LOCKED%OBJ%';
If the object exists in the dba_ table and can not be found in all_ it means you don't have the permissions for that. Execute the following for double checking
select *
from user_tab_privs
where table_name like 'V%LOCKED%OBJ%';
You'll get probably nothing here as you can't find the object, so the next thing I'd check is the role name that has access to that particular object
select *
from role_tab_privs
where table_name like 'V%LOCKED%OBJ%';
Then, check if you have that role assigned to your user
select * from session_roles
I hope this will help

use
select * from "SYS"."V$locked_objects"

Related

Informix - select from a table of another user

I have to do CRUD operations on a table that is not owned by the user I am using to connect to my Informix database. I have been granted the necessary privileges to do the operations, but I do not know how to do the actual query.
I have little experience with Informix, but I remember in OracleDB I had to do reference the shema like so:
SELECT * FROM SCHEMA.TABLE;
In Informix should I reference the user that owns the table ? Like :
SELECT * FROM OWNER:TABLE
Or can I just do :
SELECT * FROM TABLE
Thanks for any help !
In Informix you can generally use the table name without or without the owner prefix unless the database was created with mode ANSI in which case the owner prefix is required. Note that the correct syntax when using the owner is to use a period "." as in:
SELECT * FROM owner.table;
The colon is used to separate the database name as shown in the Informix Guide to SQL: Syntax https://www.ibm.com/docs/en/informix-servers/14.10?topic=segments-database-object-name#ids_sqs_1649
FYI you can determine if the database is mode ANSI with this query:
SELECT is_ansi FROM sysmaster:sysdatabases WHERE name = "<database name>";

oracle table entry does not exist

while installing sap on 3 tiered architecture, I need to install database instance (oracle) and central instance(sap) and two different machines.
after completing database install and proceeding with central instance installation, the setup is trying to access a table and fails with following error
SELECT USERID, PASSWD FROM
SAPUSER WHERE USERID IN (:A0, :A1)
OCI-call failed with
-1=OCI_ERROR SQL error 942: 'ORA-00942: table or view does not exist'
*** ERROR => ORA-942 when
accessing table SAPUSER
so I checked and found out that two cases are possible
Table does not exist or
User has no access rights to this Table
next I checked for table, and found an entry in dba_tables,
SQL> select owner from dba_tables where table_name='SAPUSER';
OWNER
------------------------------
OPS$E64ADM
but when trying to fetch data from it using select query
SQL> select * from SAPUSER;
select * from SAPUSER
*
ERROR at line 1:
ORA-00942: table or view does not exist
now I am confused, whether the table is available or not. what is the reason for this and how can it be resolved?
It depends on where you are accesing the object from,
check to see which user you are logged in as
SQL> SHOW USER
This will show which user you are logged in as,
if you are in OPS$E64ADM, the directly query using
SQL> select * from SAPUSER;
if show user show anyother user you need privilege to access it from other users, can ask dba or if you have access then run,
SQL> grant select on OPS$E64ADM.SAPUSER to username; -- the username from which you want to access the table;
then, you can acces from the other user , using,
SQL> select * from OPS$E64ADM.SAPUSER
who are you signed in as? unless it's the owner of the table you will need to change your code to include the owner ie.
select * from OPS$E64ADM.SAPUSER

why i cannot grant roles to other users [duplicate]

This question already has an answer here:
Allowing a users to select from a table
(1 answer)
Closed 8 years ago.
I am trying to grant a role to another user in Oracle. although I got : grant succeeded, it doesn't appear that the user got the role, can anyone help ?
SQL> select * from students;
no rows selected
SQL> Grant select on students to C##reine;
Grant succeeded.
SQL> disconnect
Disconnected from Oracle Database 12c Release 12.1.0.1.0 - 64bit Production
SQL> connect
Enter user-name: C##reine
Enter password:
Connected.
SQL> select * from students;
select * from students
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL>
I'm sure user C##reine has the role. If you log in as C##reine and try the following query you should see it:
SELECT * FROM User_Tab_Privs
WHERE Table_Name = 'STUDENTS';
The problem is that the table is in another schema, so C##reine needs to alias the table when querying (note that a comment posted after this answer provided the actual schema name):
SELECT * FROM C##jad.students;
To make the table visible to the user without aliasing, try this:
-- As user C##reine
CREATE SYNONYM STUDENTS FOR C##jad.STUDENTS;
User C##reine will need to have the CREATE SYNONYM system privilege.
The user needs to qualify the table with its owner schema:
select * from xyz.students

ORA-01775: looping chain of synonyms

I am creating a table (here below is the code) - this is executed through some script on unix. The script also creates some synonyms (not sure what/how):
drop table BNS_SAA_MESSAGES;
CREATE TABLE BNS_SAA_MESSAGES
(
HostNumber varchar(50) NOT NULL,
SAAMessage varchar(2048) NOT NULL,
PRIMARY KEY (HostNumber)
);
I'm getting the following error:
Processing bns_saa_messages
cat: cannot open bns_saa_messages.sql
Commit complete.
GRANT SELECT ON bns_saa_messages TO RL_ORDFX_RPT
GRANT SELECT ON bns_saa_messages TO RL_ORDFX_RPT
*
ERROR at line 1:
ORA-01775: looping chain of synonyms
GRANT INSERT ON bns_saa_messages TO RL_ORDFX_RPT
GRANT INSERT ON bns_saa_messages TO RL_ORDFX_RPT
*
ERROR at line 1:
ORA-01775: looping chain of synonyms
GRANT UPDATE ON bns_saa_messages TO RL_ORDFX_RPT
GRANT UPDATE ON bns_saa_messages TO RL_ORDFX_RPT
*
ERROR at line 1:
ORA-01775: looping chain of synonyms
GRANT DELETE ON bns_saa_messages TO RL_ORDFX_RPT
GRANT DELETE ON bns_saa_messages TO RL_ORDFX_RPT
*
ERROR at line 1:
ORA-01775: looping chain of synonyms
create public synonym bns_saa_messages for ORDMSO.bns_saa_messages
create public synonym bns_saa_messages for ORDMSO.bns_saa_messages
*
ERROR at line 1:
ORA-00955: name is already used by an existing object
Commit complete.
I googled for ORA-01775: looping chain of synonyms and it seems to mean that a something was removed but there is a pointer to it. I'm guessing it happens during select from 'things' that do not exist anymore. Not sure if these things are tables or something else. This is what I gathered from my research.
Any idea how to create my tables? I tried to execute multiple times the SQL code, but to no avail - I get the same error every time.
Also the table is not created:
SQL> select * from bns_saa_messages;
select * from bns_saa_messages
*
ERROR at line 1:
ORA-01775: looping chain of synonyms
I've looked at the following so questions, but it doesn't seem to be helping. Maybe you can see something I don't:
I get an ORA-01775: looping chain of synonyms error when I use sqlldr
How to debug ORA-01775: looping chain of synonyms?
ORA-01775: looping chain of synonyms but there are no synonyms
Thanks
:UPDATE:
After executing: select * from all_synonyms where synonym_name = 'BNS_SAA_MESSAGES'; as per Craig's suggestion I get:
OWNER SYNONYM_NAME
------------------------------ ------------------------------
TABLE_OWNER TABLE_NAME
------------------------------ ------------------------------
DB_LINK
--------------------------------------------------------------------------------
PUBLIC BNS_SAA_MESSAGES
ORDMSO BNS_SAA_MESSAGES
:UPDATE: 2
Running: select * from all_tables where table_name = 'BNS_SAA_MESSAGES';
SQL> select * from all_tables where table_name = 'BNS_SAA_MESSAGES';
no rows selected
I would run this to see where the synonym is actually pointing:
select *
from all_synonyms
where synonym_name = 'BNS_SAA_MESSAGES'
I am guessing the synonym is pointing to the wrong TABLE_OWNER.
UPDATE
So where is the table actually at? You can find this using:
select *
from all_tables
where table_name = 'BNS_SAA_MESSAGES'
If table_owner is not 'ORDMSO', then you need to either update the synonym to point to the correct location or run the Create table... script as ORDMSO.
UPDATE2
Can you run the Create table... script as ORDMSO? If not, you are going to need to have someone with higher privileges run:
select *
from dba_tables
where table_name = 'BNS_SAA_MESSAGES'
to figure out where the table really is, and then update the synonym accordingly.
It looks like the output is from running this a second time, which you hinted at; the ORA-00955 from the create public synonym shows that has been done before somewhere (as does the all_synonyms query you ran), and it clearly exists from the other errors. You wouldn't have got exactly these errors the first time you ran it, but would on every subsequent run.
At a mimimum the first code snippet should drop the public synonym before dropping the table, if you want it to be rerunnable.
But the first snippet doesn't seem to be run at all. There are no success or failure messages from Oracle. The only real clue to why is this:
Processing bns_saa_messages
cat: cannot open bns_saa_messages.sql
Which is a shell script problem, not really an Oracle one. Without seeing the shell script it's rather hard to tell quite what's wrong, but I suspect the script is building a temporary .sql file from various sources and then running it through SQL*Plus; but the vital bns_saa_messages.sql file is missing. Presumably that's where the first snippet is supposed to be; and since that seems to exist, this could beas simple as a name mismatch between the file and what the script is expecting, or the script is doing a cd and the file is in the wrong directory, or something equally trivial. But maybe not... not enough info.
Are you generating an export?
My solution with a BD oracle 11g was:
See the SYS_EXPORT objects, use Oracle SQL Developer, connect to the DB and execute the following:
Select owner, object_name, object_type, status from dba_objects where object_name like '%SYS_EXPORT%'
Objects SYS_EXPORT
Then with the user: sqlplus / as sysdba removes the created objects.
Delete objects SYS_EXPORT
SQL>drop public synonym sys_export_full_01;
SQL>drop public synonym sys_export_full_02;
SQL>drop public synonym sys_export_full_03;
SQL>drop public synonym sys_export_full_04;
After this you can generate the export.

User access issue in Oracle 11G

In my oracle DB, i have a user named test this user has DML_ROLE in the DB. And, i have provided insert/update/delete/select access to DML_ROLE on a table named hdr_detail.
But, when user test execute an update query on hdr_detail table its getting error message as Returned error: ORA-01031: insufficient privileges. It works fine when i provide the access directly to the user.
I'm confused why this error shows up only when i provide the access through role.
Table structure:
COLUMN NAME DATA TYPE
PERIOD NUMBER
HDR_ID VARCHAR2(50)
Query i use to update:
update test_sch.hdr_detail set period=201108 where hdr_id = 'check';
Statement i use to grant:
grant insert,select,update,delete on test_sch.hdr_detail to dml_role;
select * from dba_role_privs where grantee like 'TEST' returns the following result
GRANTEE GRANTED_ROLE ADMIN_OPTION DEFAULT_ROLE
TEST DML_ROLE NO NO
select * from dba_tab_privs where table_name like 'HDR_DETAIL' returns the following result
GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE GRANTABLE HIERARCHY
DML_ROLE TEST_SCH HDR_DETAIL TEST_SCH DELETE NO NO
DML_ROLE TEST_SCH HDR_DETAIL TEST_SCH INSERT NO NO
DML_ROLE TEST_SCH HDR_DETAIL TEST_SCH SELECT NO NO
DML_ROLE TEST_SCH HDR_DETAIL TEST_SCH UPDATE NO NO
Please help me in resolving this issue. Reply in comment if any more information is needed about this issue.
Try setting the role as the users default role:
ALTER USER test DEFAULT ROLE dml_role;
It could be an issue with how you are accessing the databse object HDR_DETAIL.
From Don burleson (http://www.dba-oracle.com/concepts/roles_security.htm):
Oracle roles have some limitations. In particular object privileges are granted through Oracle roles can not be used when writing PL/SQL code. When writing PL/SQL code, you must have direct grants to the objects in the database that your code is accessing.
If your user is issuing the UPDATE through an application or PL/SQL block then it will not use the role-based permissions. If this is the case you will have to grant the permissions directly.
That seems impossible.
Are you sure that your user connect to correct DB, schema, and query the right table?
I'm stunned.
Pls try
select * from test_sch.hdr_detail
wiht test user.

Resources