Getting ORA-01031: insufficient privileges while querying a table instead of ORA-00942: table or view does not exist

后端 未结 5 1347
粉色の甜心
粉色の甜心 2021-02-08 06:01

When I\'m querying a table in schema C from schema A, I\'m getting ORA-01031: insufficient privileges and when I\'m querying the same table from schema B, I\'m

5条回答
  •  臣服心动
    2021-02-08 06:34

    for ORA-01031: insufficient privileges. Some of the more common causes are:

    1. You tried to change an Oracle username or password without having the appropriate privileges.
    2. You tried to perform an UPDATE to a table, but you only have SELECT access to the table.
    3. You tried to start up an Oracle database using CONNECT INTERNAL.
    4. You tried to install an Oracle database without having the appropriate privileges to the operating-system.

    The option(s) to resolve this Oracle error are:

    1. You can have the Oracle DBA grant you the appropriate privileges that you are missing.
    2. You can have the Oracle DBA execute the operation for you.
    3. If you are having trouble starting up Oracle, you may need to add the Oracle user to the dba group.

    For ORA-00942: table or view does not exist. You tried to execute a SQL statement that references a table or view that either does not exist, that you do not have access to, or that belongs to another schema and you didn't reference the table by the schema name.

    If this error occurred because the table or view does not exist, you will need to create the table or view.

    You can check to see if the table exists in Oracle by executing the following SQL statement:

    select *
    from all_objects
    where object_type in ('TABLE','VIEW')
    and object_name = 'OBJECT_NAME';
    

    For example, if you are looking for a suppliers table, you would execute:

    select *
    from all_objects
    where object_type in ('TABLE','VIEW')
    and object_name = 'SUPPLIERS';
    

    OPTION #2

    If this error occurred because you do not have access to the table or view, you will need to have the owner of the table/view, or a DBA grant you the appropriate privileges to this object.

    OPTION #3

    If this error occurred because the table/view belongs to another schema and you didn't reference the table by the schema name, you will need to rewrite your SQL to include the schema name.

    For example, you may have executed the following SQL statement:

    select *
    from suppliers;
    

    But the suppliers table is not owned by you, but rather, it is owned by a schema called app, you could fix your SQL as follows:

    select *
    from app.suppliers;
    

    If you do not know what schema the suppliers table/view belongs to, you can execute the following SQL to find out:

    select owner
    from all_objects
    where object_type in ('TABLE','VIEW')
    and object_name = 'SUPPLIERS';
    

    This will return the schema name who owns the suppliers table.

提交回复
热议问题