Ora-01031 create view

Hi,
I'm trying to create a view as a select from tables of a diferent schema. I have create view privilege on my user, and select previlege on tables from the other schema.
The select instructions run's ok in my schema and I can obtain results.
But when I copy paste the select into a create view as instruction, it returns ora-01031.
Can anyone help me?
Thanks...
Ricardo Feliciano

in general everyone who owns an oracle user can select every table on the
user of the aplication, Personally I think that is wrong. It's just not the way I build applications. However, if everybody did everything the same there wouldn't be any fun.
However, if that's the general rule, then I don't see why you need rules. All you need is a parameterised script which accepts the name of a user and grants them SELECT on all the application owner's tables.
If someone wants a view over object's they can view why not.I have a different philosophy of schema design. I think most users shouldn't have any DDL privileges so the question never arises.
Cheers, APC
Blog : http://radiofreetooting.blogspot.com/

Similar Messages

  • ORA-01031 when creating a view

    Hi guys,
    I transported a view(custom view ZVIEW) from Development to Production and found that the view was missing the database of the production system.
    When i tried to create the same view usin SE14 am getting a warning
    ORA-01031: insufficient privileges                     
    DDL time(___1): .......119 milliseconds                
    The SQL statement was not executed                     
    Statements for View ZVIEW_STD_TIME could not be executed
    Request for ZVIEW_STD_TIME could not be executed       
    in the system the SAPR3 and OPS$PRDADM has sysdba privilege so i guess SYSCONN need not be implemented.
    Please help.
    Thanks and regards,
    Siddhartha

    Hi Rabi,
    Check below sap notes.
    Note 985607 - ORA-01031 Creating views after upgrade to Oracle 10g
    Note 1028220 - ORA-01031: Insufficient privileges despite SAPCONN role
    Regards
    Ashok

  • Using database-link in view to get around ORA-01031 error

    I have been granted select rights on a users table. I am therefore able to select from his table. If however I try create a view against his table I run into the ORA-01031 problem. I have worked around this problem by creating a database-link to myself and then adding that to the view creation and it works. What are the downsides of using the database-link in this way?

    The only down side I have been able to identify is that a extra session is created and that the CPU has a little extra work due to the LOOP BACK that takes place. I need to ensure the network is not unnessesarly used and therefore will need to ensure that 127.0.0.1 (local host) is used in the database connection discription. e.g.
    create database link my_db_link connect to scott identified by tiger using '(description=(address=(protocol=tcp)(host=127.0.0.1) (Port = 1521) ) (connect_data= (sid=ora10g)))';

  • Create view and alter Session gets 0RA-01031

    I can't create a view after using ALTER SESSION set current_schema without using an explicit schema. I get ORA-01031. Is this a known bug? Here are the details:
    1. Log on as SYSTEM
    2. ALTER SESSION set current_schema=FRED;
    3. CREATE VIEW vFoo as select * from Foo;     -- ORA-01031: insufficient privileges
    4. CREATE VIEW FRED.vFoo as select * from Foo;     -- this works!
    I've read where some privileges need to be granted directly. In fact, if Fred grants select privilege on Foo to SYSTEM, the statement in #3 above works. However, something doesn't seem right because why does #4 succeed without the GRANT?
    In case you're wondering why I don't just use #4 above, which does work, it's because I've got a script that will be run by customers to create tables, views, etc. in an arbitrary schema and the schema is associated with a user with limited permissions. Hence, the use of the ALTER SESSION.

    See, You looged as SYSTEM (Scheme = SYSTEM)
    Now you alter your session to another schema FRED.
    Now if you want to access SCHEMA of FRED, You need to connect first.
    SQL > connect user/password@host
    Then
    SQL > CREATE VIEW vFoo as select * from Foo;
    View created.

  • ORA-01031 SYSMAN Insufficient Privileges Creating a new user

    I have installed Oracle 11g R2 onto Windows 7 64bit
    I then created a new database, at the end it moaned about the service and listener was not running or allocated to each other and also there was no web admin tool available.
    To resolve this I managed to use Net Configuration Assistant to get the listener sorted.
    I then had to run:
    set ORACLE_HOSTNAME=localhost
    set ORACLE_SID=mydb
    set ORACLE_UNQNAME=mydb
    I then ran
    emca -config dbcontrol db -repos recreate
    This gave me the web admin tool to create a new user.
    I logged in as SYSMAN tried to create a new user and got the "ORA-01031 Insufficient Privileges, you do not have enough privileges to perform this operation." error
    Can someone please help.
    Thanks

    It isn't that simple. As SYSMAN used for 11.2.0.3 database control:
    orcl>  select privilege from user_sys_privs;
    PRIVILEGE
    CREATE PUBLIC SYNONYM
    SELECT ANY DICTIONARY
    UNLIMITED TABLESPACE
    ALTER SESSION
    orcl>but as SYSMAN used for 12.1 Cloud Control:SQL> select privilege from user_sys_privs;
    PRIVILEGE
    ALTER USER
    DROP USER
    CREATE SESSION
    CREATE PUBLIC SYNONYM
    CREATE JOB
    CREATE MATERIALIZED VIEW
    SELECT ANY DICTIONARY
    CREATE TABLE
    ALTER SESSION
    CREATE USER
    CREATE SYNONYM
    DROP PUBLIC SYNONYM
    MANAGE SCHEDULER
    CREATE VIEW
    CREATE DATABASE LINK
    15 rows selected.
    SQL>so you have to be a bit careful when you give a yes/no answer.
    Edited by: JohnWatson on Nov 12, 2012 11:38 AM
    Forgot to include a quote: this is replying to the question about whether SYSMAN can create users.

  • Error while selecting from a view ORA-01031: Insufficient privileges

    As DBA I have granted select privileges on a view to a user, but whenever I login as that user and try to select from the view I get the message 'ORA-01031'. When I run the query in the view as the user I do not have problem and can see the results. This view joins tables from more than one schema and does a distinct on the resultset. I am new to Oracle and would appreciate any help I can get.
    Thanks

    Back on this problem when I created another user with select permission on the same view and a default role that has reference on all the objects on the other schemas, I end up with the same error message. Although this time the schema owner of the view has select privileges on all the tables from other schemas referenced in the view.
    Thanks

  • View, instead of trigger and ORA-01031

    Hello,
    I have a view based on outer joins like
    CREATE VIEW vt ( colV1, colV2, colV3, colV4, colV5, colV6, colV7, colV8 ) AS
    SELECT A.colA1, A.colA2, C.colB0, B.colB2, B.colB3, B.colB4, C.colC2, H.colH2
      FROM  tabA    A
           ,tabB    B
           ,tabC    C
           ,( SELECT  ...
                FROM   tabD  D
                      ,tabE  E
                WHERE  D.colD1 = E.colE1
             )  H                                
      WHERE A.colA1 = B.colB1
        AND LTRIM(B.colB2,'A') = LTRIM(C.colC1(+),'A')    
        AND B.colB3 = H.colH1(+); and an instead of trigger
    CREATE OR REPLACE TRIGGER vt_upd
      INSTEAD OF UPDATE ON vt
    BEGIN
      UPDATE    tabB
         SET    colB4 = :NEW.colV6
         WHERE  colB0 = :NEW.colV2;
    END;An now the problem: an update statement UPDATE vt set colV6=1 WHERE colV1=1; in SQL*Plus works as it should, but performing an update in APEX from a tabular or edit form shows an error: ORA-01031:ORA-01031: insufficient privileges, update...The strange thing: in both sessions there is the same user USER1 logged on !
    Why this difference ? Can anybody explain ?
    Regards,
    Heinz

    Hi Heinz,
    Your statement -
    what I wrote as table tabC in reality is a view to one table and one view in another schema.That'll be it, you need to grant explicit rights for the objects in that schema to the schema that is your parsing schema for your workspace.
    In other words, if you have -
    1) Workspace 'A' with parsing schema 'B'
    and you are trying to do -
    select foo from c.bar
    i.e. you're trying to query an object in schema 'C'.
    Then you need to (as a DBA or connected to schema C) -
    grant select on bar to b;Roles won't work (when used through APEX)...I can't say that any other way, you might find it works in SQLPlus with roles, but through APEX it won't...you need those explicit grants.
    Hope this makes sense.
    John.

  • ORA-01031 with materialized view in stored procedure

    USER1 has created a materialized view (MV). The MV is owned by USER2. USER1 needs to query the MV from within a stored procedure. How do I avoid the ORA-01031?
    Here's the illustration:
    SQL> show user
    USER is "USER1"
    SQL> CREATE MATERIALIZED VIEW USER2.ROLL
    2 BUILD IMMEDIATE
    3 REFRESH COMPLETE WITH ROWID
    4 ON DEMAND
    5 AS
    6 select * from user2.test_roll;
    Materialized view created.
    SQL> select status,owner,object_name,object_type where OBJECT_TYPE='MATERIALIZED VIEW';
    STATUS OWNER OBJECT_NAME OBJECT_TYPE
    VALID USER2 ROLL MATERIALIZED VIEW
    SQL> select count(*) from user2.roll;
    COUNT(*)
    959485
    SQL> declare
    2 n number;
    3 begin
    4 select count(*)
    5 into n
    6 from user2.roll
    7 where rownum<100;
    8 dbms_output.put_line(n);
    9* end;
    SQL> /
    99
    PL/SQL procedure successfully completed.
    SQL> create procedure test_mv is
    2 n number;
    3 begin
    4 select count(*)
    5 into n
    6 from as400_snpsht.roll
    7 where rownum<100;
    8 dbms_output.put_line(n);
    9 end;
    10 /
    Warning: Procedure created with compilation errors.
    SQL> select text from user_errors where name like 'TEST_MV';
    TEXT
    PL/SQL: ORA-01031: insufficient privileges
    PL/SQL: SQL Statement ignored
    So the point is:
    * Ad hoc sql works on the MV
    * Anonymous pl/sql works on the MV
    * Stored procedure fails compilation with ora-01031
    Any suggestions are appreciated.

    Sorry; In may example 'as400_snpsht' should have been 'USER2' (the owner of the MV). I changed the real user names to USER1, USER2 to make the example clearer but missed that one.
    I meant to say...
    SQL> create procedure test_mv is
    2 n number;
    3 begin
    4 select count(*)
    5 into n
    6 from user2.roll
    7 where rownum<100;
    8 dbms_output.put_line(n);
    9 end;
    10 /
    Warning: Procedure created with compilation errors.
    SQL> select text from user_errors where name like 'TEST_MV';
    TEXT
    PL/SQL: ORA-01031: insufficient privileges
    PL/SQL: SQL Statement ignored

  • ORA-01031 insufficient privileges  error when selecting from a view

    OK I think this might be a dumb question but I can't figure it out:
    User John has been granted SELECT privilege (directly, not through a database role) to schema FRED.table1;
    User John can issue select * from FRED.table1; and it works just fine.
    User John has then been granted SELECT privilege (directly, not via a database role) to schema
    MARK.view1;
    MARK.view1 only selects from FRED.table1. No other tables are in the view1.
    Schema MARK can successfully query the views. SELECT * FROM VIEW1 returns results.
    I also checked the MARK schema to ensure that it has been granted SELECT on FRED.table1 directly which it has.
    Now, when logged into schema John, I try SELECT * FROM MARK.VIEW1; and I get ORA-01031 insufficient privileges error.
    I'm not sure how to troubleshoot this. If John is granted SELECT ANY TABLE, it of course works but I don't want John to have that powerful priv.
    To recap, John has SELECT on both MARK.VIEW1 and the table which VIEW1 selects from (FRED.TABLE1).
    John can select from FRED.TABLE1 no problem but receives a privilege error even though John has SELECT on MARK.VIEW1.
    Any thoughts?
    Oh, Oracle EE 10.2.0.4

    JSebastian wrote:
    OK I think this might be a dumb question but I can't figure it out:
    User John has been granted SELECT privilege (directly, not through a database role) to schema FRED.table1;
    User John can issue select * from FRED.table1; and it works just fine.
    User John has then been granted SELECT privilege (directly, not via a database role) to schema
    MARK.view1;
    MARK.view1 only selects from FRED.table1. No other tables are in the view1.
    Schema MARK can successfully query the views. SELECT * FROM VIEW1 returns results.
    I also checked the MARK schema to ensure that it has been granted SELECT on FRED.table1 directly which it has.
    Now, when logged into schema John, I try SELECT * FROM MARK.VIEW1; and I get ORA-01031 insufficient privileges error.
    I'm not sure how to troubleshoot this. If John is granted SELECT ANY TABLE, it of course works but I don't want John to have that powerful priv.
    To recap, John has SELECT on both MARK.VIEW1 and the table which VIEW1 selects from (FRED.TABLE1).
    John can select from FRED.TABLE1 no problem but receives a privilege error even though John has SELECT on MARK.VIEW1.
    Any thoughts?
    Oh, Oracle EE 10.2.0.4Are you certain John has been granted select on Mark.view1 ? In order for that to work Mark would have to have been given select on Fred.table1 WITH GRANT OPTION ... otherwise the grant would fail and then John would not be able to select from the view because the grant was never successfully issued.
    Here's a basic test case (which i think conforms to what you've outlined) to get it working.
    drop user u1 cascade;
    drop user u2 cascade;
    drop user u3 cascade;
    create user u1 identified by u1;
    grant connect, resource to u1;
    create user u2 identified by u2;
    grant connect, resource, create view to u2;
    create user u3 identified by u3;
    grant connect, resource to u3;
    connect u1/u1@orcl
    create table test1 (col1 number);
    grant select on test1 to u2 with grant option; --> this is the important part
    grant select on test1 to u3;
    connect u2/u2@orcl
    create view test2 as select * from u1.test1;
    grant select on test2 to u3;
    connect u3/u3@orcl
    select * from u2.test2;

  • Why do I get a "ORA-01031: insufficient privileges" in my view creation?

    Why do I get a "ORA-01031: insufficient privileges" in my view creation for the table which exists in the same schema?
    Oracle version is 10g R2.
    connect cim/lion;
    create table cim.table1 (a number, b varchar2(10));
    create view cim.view1 as select * from cim.table1;
    create view cim.view1 as select * from cim.table1
    ERROR at line 1:
    ORA-01031: insufficient privileges

    Thanks it works now after giving CREATE VIEW permission to user CIM.
    This script was working fine in Oracle 10g R1.
    Looks like i need to execute the following GRANT permission explicitly
    grant create view to cim;

  • Error while Creating Master Repository: ORA-01031: insufficient Privileges

    Hi,
    I'm trying to install ODI into my VM.
    I have done the installation and while creating Master Repository, I'm getting following error:
    ORA-01031: insufficient Privileges
    I'm using Oracle & have created user as ODI_MASTER with Admin Privileges.
    I'll be using it to load metadata onto planning (Version 11.1.2)
    Is there anything that I'm missing out on.
    Jitendra.

    Seems missing grants on the user you are using to create Master Repository.
    you are using Oracle .. grant connect, resource to <your_user>. These two rolesa have sufficient access to db to create the master repository.
    execuute the sql from sys user
    Regards,
    Amit
    Edited by: amitgupta1202 on 20 Aug, 2009 10:42 PM

  • ORA-01031: insufficient privileges when creating a table in other schema

    Dear all,
    I appreciate your help please in this issue :
    when i try to issue the below statement to create a table in an another schema than the user i am connected in
    CREATE TABLE SCHEMA_NAME_B.HST_ARCH nologging AS
    SELECT *
    FROM HST
    WHERE 1 = 0;
    I always get ORA-01031: insufficient privileges error, even if i have granted the create table privilege to the user i am connected in.
    What other privileges should i grant also,
    Please if you have any idea.

    user562674 wrote:
    Dear all,
    I appreciate your help please in this issue :
    when i try to issue the below statement to create a table in an another schema than the user i am connected in
    CREATE TABLE SCHEMA_NAME_B.HST_ARCH nologging AS
    SELECT *
    FROM HST
    WHERE 1 = 0;
    I always get ORA-01031: insufficient privileges error, even if i have granted the create table privilege to the user i am connected in.
    What other privileges should i grant also,
    Can you show us a cut/paste from the sql*plus of session of yours which should show that you have given the privilege directly to this user and after that the command fails?
    Aman....

  • View with Instead of Trigger - ORA-01031

    I am having trouble with a form based on a view that uses an instead of trigger.
    When I attempt to update a complex view that uses instead of triggers in an APEX form, I get the following message:
    ORA-20001: Error in DML: p_rowid=21388, ... ORA-01031: insufficient privileges
    The view works correctly when updates are executed from SQL Plus.
    The view "VW" is based on several tables in the application schema "X", which is parsed by APEX, and several tables in another schema "Z". I have explicitly granted select permission on the tables in schema "Z" to schema "X", but this doesn't resolve the error.
    Any idea how to fix this problem? From reading other posts, it sounds like the only issue should be explicit grants on the tables in other schemas. I do not attempt to update the tables in schema "Z", and do not have update permissions to those tables.
    Sinerely, Justin

    Justin,
    you might try to grant the views to the FLOWS_xxxxx user, which performs the Apex processes.
    Dik Dral

  • Creating view containing case statements received error ORA-22992

    We have a create view referencing table through dblink. The select statement in the create view has case statements, when running the Select statement alone, results are return. However, when executing the create view, it returns:
    SQL Error: ORA-22992: cannot use LOB locators selected from remote tables
    22992. 00000 - "cannot use LOB locators selected from remote tables"
    *Cause:    A remote LOB column cannot be referenced.
    *Action:   Remove references to LOBs in remote tables.
    One of the source table has LOB column but not in the select statement. The strange thing is when removing the case statement from the select, create view works fine. Can anybody tell me what caused the error and how to fix it?
    Create View Snippet:
    CREATE OR REPLACE VIEW "ABC"."XYZ" (....
    AS SELECT
    CASE
    WHEN A.OUTAGE =1
    THEN 'Y'
    ELSE 'N'
    END AS OUTAGE,
    FROM
    TABLEA@XXXX A
    LEFT JOIN TABLEB@XXXX B
    ON
    A.LOC =B.LO
    AND A.SITE =B.SITE
    WHERE
    A.CLASS ='CUSTOMER'
    AND A.PLUSSISGIS =1;

    What is your 4 digit Oracle version?
    Try rewriting the query to not use ANSI SQL92 joins. I found a link where this solved a problem similar to yours.
    DBLink problem ORA-22992
    >
    But, look at this curious thing: I re-write the query as follows:
    SELECT A.ID, A.ID_REF, A.EVENDATE, B.DESCRIPTION
    FROM A@ORCL A, B@ORCL B
    WHERE A.ID_REF = B.ID_REF;
    and it works fine... It seems like Oracle don't like the ANSI SQL92...
    >
    Several similar links by googling: 'SQL Error: ORA-22992'
    http://www.dbuggr.com/smallwei/solution-error-ora-22992-lob-locators-selected-remote-tabl/
    >
    Fixing ORA-22992 “cannot use LOB locators selected from remote tables” error
    You have migrated your Oracle 9i database to 10g and a distributed statement which worked fine in 9i now is getting error ORA-22992 “cannot use LOB locators selected from remote tables”. Even though the related remote table(s) does not contain any LOB column datatype.
    FIX:
    There is a bug on 9i,10g, and 11g that is related to this error. It is being fixed in 11.2. It can also be backported for previous 9i, 10g and 11g releases under the latest patchsets.
    You may also do a workaround as follow:
    Modify the affected SQL by adding the TO_CHAR function. For example:
    -- Original SQL:
    SELECT NVL2('a', 'b','c' ) FROM dual@remote_db;
    -- Modified SQL:
    SELECT TO_CHAR(NVL2('a','b','c')) FROM dual@remote_db;
    >
    See if that helps.

  • ORA-04052 creating Materialized View

    ORA-04052 creating Materialized View
    Hi All !!
    I'm trying to create a Materialized view and his query definition uses an active public database link. When I ran the script for creating the view I get the following message:
    ERROR in line 1:
    ORA-04052: error occurred when looking up remote object
    USER.TABLE@ORCL2
    ORA-00604: error occurred at recursive SQL level 1
    ORA-03106: fatal two-task communication protocol error
    ORA-02063: preceding line from ORCL2
    But when I execute his definition query all is ok, the query works fine.
    I mean, I'm using the following sentence to create the view:
    CREATE MATERIALIZED VIEW my_view TABLESPACE tbsname BUILD IMMEDIATE
    REFRESH FORCE
    WITH ROWID
    ENABLE QUERY REWRITE
    AS
    SELECT ...
    FROM SCHEMA_NAME.TABLE_NAME@ORCL2;
    The above sentence give me ORA-04052. Nevertheless the SELECT... FROM SCHEMA_NAME.TABLE_NAME@ORCL2; works fine...
    I checked for the GLOBAL_NAMES parameter and it is set to FALSE. Please help me, How can I fix this problem ?
    I'm using Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production running over Win XP for create the view.
    The Database Link points to Oracle Database 10g Release 10.1.0.4.0 - 64bit Production running over Solaris
    Thanks in advance !!

    I've checked the NLS_LANG settings in both servers, and are set to AMERICAN. NLS TERRITORY are set to America also.

Maybe you are looking for