Create a view based on a public synonym

Hi I'm trying to create a view based on a public synonym, but getting "ORA-01031: insufficient privileges" error.
When i retrieve records from the same public synonym, i could able to do so. But when i try to create a view based on that synonym, it is not possible. Why is it? Can anyone please explain?
11:58:04 IT00053.it0053@SCOTT> connect sys as sysdba
Enter password: ******
Connected.
11:58:14 IT00053.it0053@SYS> create role general_user_role;
Role created.
Elapsed: 00:00:00.14
11:58:33 IT00053.it0053@SYS> connect scott
Enter password: *****
Connected.
11:58:41 IT00053.it0053@SCOTT> select * from tab;
TNAME TABTYPE CLUSTERID
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
DEPT_TAB SYNONYM
Elapsed: 00:00:00.01
11:58:47 IT00053.it0053@SCOTT> create public synonym scott_emp for scott.emp;
Synonym created.
Elapsed: 00:00:00.06
11:59:14 IT00053.it0053@SCOTT> grant select on scott_emp to general_user_role;
Grant succeeded.
Elapsed: 00:00:00.14
11:59:35 IT00053.it0053@SCOTT> connect sys as sysdba
Enter password: ******
Connected.
12:00:13 IT00053.it0053@SYS> create user beginning_user
12:00:31 2 identified by beginning_user
12:00:38 3 default tablespace users
12:00:45 4 temporary tablespace temp;
User created.
Elapsed: 00:00:00.04
12:00:53 IT00053.it0053@SYS> grant connect, resource, create table, create view to beginning_user;
Grant succeeded.
Elapsed: 00:00:00.01
12:01:13 IT00053.it0053@SYS> grant general_user_role to beginning_user;
Grant succeeded.
Elapsed: 00:00:00.01
12:01:35 IT00053.it0053@SYS> connect beginning_user/beginning_user
Connected.
12:01:49 IT00053.it0053@SYS> connect beginning_user
Enter password: **************
Connected.
12:02:01 IT00053.it0053@SYS> show user
USER is "BEGINNING_USER"
12:02:06 IT00053.it0053@SYS> select * from scott_emp;
EMPNO ENAME JOB MGR HIREDATE SAL
COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800
20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600
300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250
500 30
7566 JONES MANAGER 7839 02-APR-81 2975
20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250
1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850
30
7782 CLARK MANAGER 7839 09-JUN-81 2450
10
7788 SCOTT ANALYST 7566 19-APR-87 3000
20
7839 KING PRESIDENT 17-NOV-81 5000
10
7844 TURNER SALESMAN 7698 08-SEP-81 1500
0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100
20
7900 JAMES CLERK 7698 03-DEC-81 950
30
7902 FORD ANALYST 7566 03-DEC-81 3000
20
7934 MILLER CLERK 7782 23-JAN-82 1300
10
14 rows selected.
Elapsed: 00:00:00.21
12:02:16 IT00053.it0053@SYS> create or replace view new_view_1 as select empno, ename, job from
12:02:50 2 scott_emp;
scott_emp
ERROR at line 2:
ORA-01031: insufficient privileges
Why is this error?
Your help will be much appreciated...
Thanks and regards
Muthu

create any view privilege
10:15:07 IT00053.it0053@SYS> connect sys as sysdba
Enter password: ******
Connected.
10:22:27 IT00053.it0053@SYS>
10:22:28 IT00053.it0053@SYS>
10:22:28 IT00053.it0053@SYS> grant create any view to beginning_user;
Grant succeeded.
Elapsed: 00:00:00.00
10:22:53 IT00053.it0053@SYS> connect beginning_user/beginning_user
Connected.
10:22:59 IT00053.it0053@SYS> create or replace view new_view_1 as select empno, ename, job from scot
t_emp;
create or replace view new_view_1 as select empno, ename, job from scott_emp
ERROR at line 1:
ORA-01031: insufficient privileges
---> Same result
But When creating a view, the owner must have granted the select directly.
10:23:08 IT00053.it0053@SYS> connect scott/tiger
Connected.
10:25:43 IT00053.it0053@SCOTT> grant select on scott_emp to beginning_user;
Grant succeeded.
Elapsed: 00:00:00.07
10:26:14 IT00053.it0053@SCOTT> connect beginning_user/beginning_user
Connected.
10:26:19 IT00053.it0053@SCOTT> create or replace view new_view_1 as select empno, ename, job
10:26:25 2 from scott_emp;
View created.
Elapsed: 00:00:00.03
This works. Thanks a lot for your timely help.
danke shun herr bochum. thanks to mr.ankara

Similar Messages

  • How to create a view based on Lookup Column?

    Hi All,
    I am working as a SharePoint developer 2013.
    When i tried to create a view based on look up column it is not showing lookup column.
    How to fix this problem?
    Please help me out here.
    Thanks & Regards,
    Santhoshi

    can you elaborate the issue? Do you mean you cannot view the column name in the filter section when creating a new view for the list or the column is not getting displayed in the view created?
    --Cheers

  • How to create materialized view based on a synonym

    Hi all,
    I am trying to create simple materialized view based on a synonym and that synonym is pointing a view in other database (using dblink). I am getting table or view not found error . I am able to select synonym if i use select but not in materialized view. Please help me.
    Thanks,

    The best way to do this is to create a materialzed view based on the underlying code of the original view. If you don't have this handy, issue the following in sqlplus:
    select text
    from user_views
    where view_name = 'NAME_OF_VIEW'
    You can then cut and paste the sql statement into your create materialized view statement.
    Please note, you will probable have to set the long parameter to a higher value to reveal the complete statement for example:
    SQL> set long 2048

  • How to create materialized view based on a view?

    Hi,
    I hope this is not very far fetched idea.
    I have a very complex view and I would like to replicate it 'in place' that is I would like to make a materialized view that is based on this view complex view. I would like to use this materialized view (i.e table) to query data instead of using the original view, since it takes Oracle some 10-15 seconds to execute my query on the original view and I am not allowed to create indexes on most of the tables that are included in the original view.
    Can this be done?
    Best regards,
    Tamas Szecsy

    The best way to do this is to create a materialzed view based on the underlying code of the original view. If you don't have this handy, issue the following in sqlplus:
    select text
    from user_views
    where view_name = 'NAME_OF_VIEW'
    You can then cut and paste the sql statement into your create materialized view statement.
    Please note, you will probable have to set the long parameter to a higher value to reveal the complete statement for example:
    SQL> set long 2048

  • List View Filter - I want to create List View based on a specific user

    I want to create a List View Filter based on specified user ID. I dont want to specify the [Me] for filtering the view based in current logged in User.
    I want the view to be based on specific user ID for Ex: "AD\JohnDoe"
    Thanks
    Nate

    The People/Group Picker field has several options for how the name is displayed. For example you can set it to be the friendly name or the account name. When you create your View Filter, make sure that you are using the same format as the field's display
    type.
    Dimitri Ayrapetov (MCSE: SharePoint)

  • Create a view based off a query in Access WebApp

    I'm trying to create a summary view based on a query.  The query is being used to make a simple join two tables.  I don't have an issue creating a datasheet or list view off the query, but when I try to create a summary view, I'm unable to
    create it.
    From the desktop app, I'm able to click on the plus sign to add a new view, give it a name, choose the type and select my record source.  When I click on "Add New View" nothing happens.  I do not get any progress dialog box as I do for
    other views.  The popup for the "Add New View" simply disappears.  Is this the expected behavior?
    Based on this thread I don't think so.
    https://social.msdn.microsoft.com/Forums/en-US/a5e60abc-0061-429e-8ce8-2014626c42c2/access-web-app-open-a-subform-from-a-query-based-summary-view?forum=accessdev
    Again, this is a simple query table 1 has 8 colums, all of them are simple text except for one lookup column that includes the data with the table, one column stores the a primary key from the second table.  The second table is a simple table with
    3 columns. 
    Is this a limitation of the Access Web App?

    Hi,
    You should be able to create a new summary view off a saved query. The behavior you describe sounds very odd but I’m not able to repro this on my computer. Could
    you try something for me? Try and create a new summary view and use a table as its record source. Does that get created OK?
    Jeff Conrad - Access Junkie - MVP Alumnus
    Senior Content Developer - Modern Assistance and Support Experience - Microsoft Corporation
    Author - Microsoft Access 2013 Inside Out
    Author - Microsoft Access 2010 Inside Out
    Co-author - Microsoft Office Access 2007 Inside Out
    Access 2007/2010/2013 Info: http://www.AccessJunkie.com
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/en-us/legal/Copyright/Default.aspx

  • Create Materialized View based on Results from LDAP Query

    Hi -- I'm trying to create a materialized view based on results from an LDAP query. Unfortunately, it looks like a materialized view can't be created based on a stored procedure, which is where the LDAP results are obtained (using nested loops).
    Does anyone have any idea how to do this without first kicking off a stored procedure that populates a temp table which would be used to create the materialized view? I'm trying to minimize the steps that the DBA's will need to go through when refreshing this new view.
    Thanks,
    ~Christine

    Can you give us more details about the stored procedure you're calling. It will help to know what parameters are involved and what data types they are.
    Off the top of my head though it looks like, at the very least, you would need a stored function that calls the stored procedure. I don't think there is any way to call stored procedures from CREATE ... commands. If you're going to create a stored function anyway ... well, you might as well just create a procedure that inserts values into a regular table instead of fussing with functions and materialized views. You'll probably want to schedule your new procedure to run periodically since it sounds like you'll need the values refreshed from time to time.

  • Can I create a view based on two tables that have the same column name?

    I have two tables A and B. Each table has 50+ columns.
    I want to create a view that includes all the columns in A and all the columns in B. I created a view with a select statement that says
    Select A.*, B.*
    From A, B
    where A.id = B.id
    It returns an error because in each table I have a column that keeps track if a record has been changed called Modified_By. That's where it chokes up on I figure. I would like to write the view without explicitly writing each column name from A and B as part of the select statement. The actual select statement works fine and only bombs when trying to turn the select statement into a view.

    You will have to type the full column list at least once. You can save a few keystrokes (i.e. alias. on every column) by providing the column names to the CREATE part instead of in the SELECT part. Something like:
    SQL> desc t
    Name                                      Null?    Type
    ID                                                 NUMBER
    NAME                                               VARCHAR2(10)
    SQL> desc t1
    Name                                      Null?    Type
    T_ID                                               NUMBER
    LOC_ID                                             NUMBER
    NAME                                               VARCHAR2(15)
    SQL> CREATE VIEW t_v (id, t_name, t_id, loc_id, t1_name) AS
      2  SELECT t.*, t1.*
      3  FROM t, t1
      4  WHERE t.id = t1.t_id;
    View created.HTH
    John

  • Create a view based on a view

    I am editing a created view, VIEW_B. When I looked at the code, it is selecting from another view, VIEW_A.
    VIEW_A : Select * from Emp
    VIEW_B : Select * from VIEW_A where sal > 1000
    Is it advisable to continue having a view selecting from another view or is it better for VIEW_B to be Select * from Emp where sal > 1000? I tried doing both and the performance was the same. However, I do not know if this will work with all of the views created that I need to edit, if there are factors that affect performance.
    If you guys know any documentation on this or have any experience regarding this matter, please let me know.
    Thanks!

    it depends and there is no standard approach as to when a view should include another view. mostly i see this approach whenever grouping is needed. this is to say that one view is a grouping of mostly related columns and creating another view to include that view which has the grouping. i observed that is an approach that some developers use instead of using a inline views - the sub-query part that is use in the FROM clause. the same view can be use to other codes without having to re-type the sub-query.

  • Create Materialized View  based on another database table using db link?

    SQL> SELECT sysdate
    2 FROM dual@CBRLINK ;
    SYSDATE
    21-NOV-12
    SQL> CREATE MATERIALIZED VIEW USERCBR.V_T24_COUNTRY1
    2 REFRESH COMPLETE
    3 START WITH SYSDATE NEXT SYSDATE + (5/24)
    4 AS
    5 SELECT sysdate
    6 FROM dual@CBRLINK ;
    CREATE MATERIALIZED VIEW USERCBR.V_T24_COUNTRY1
    ERROR at line 1:
    ORA-04052: error occurred when looking up remote object SYS.DUAL@CBRLINK
    ORA-00600: internal error code, arguments: [ORA-00600: internal error code,
    arguments: [qksfroFXTStatsLoc() - unknown KQFOPT type!], [0], [], [], [], [],
    ORA-02063: preceding line from CBRLINK

    It works for me:orcl>
    orcl> CREATE MATERIALIZED VIEW scott.V_T24_COUNTRY1
      2  REFRESH COMPLETE
      3  START WITH SYSDATE NEXT SYSDATE + (5/24)
      4  AS
      5  SELECT sysdate
      6  FROM dual@l1 ;
    Materialized view created.
    orcl> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for 32-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    orcl>so there is no problem with the code. HTH.

  • Creating a view based on XMLType col

    I have a table with one column EMPDATA of type XMLTYPE. I have one record in the table with the following xml data:
    <Employee xmlns="http://www.oracle.com/empl2.xsd" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <EmployeeId>2</EmployeeId>
         <Name>String</Name>
         <Job>String</Job>
         <Manager>2</Manager>
         <HireDate>1967-08-13</HireDate>
         <Salary>2</Salary>
         <Commission>2</Commission>
         <Dept>
              <DeptNo>2</DeptNo>
              <DeptName>Dept Name 1</DeptName>
              <Location>Location 1</Location>
         </Dept>
         <Dept>
              <DeptNo>2</DeptNo>
              <DeptName>Dept Name 2</DeptName>
              <Location>Location 2</Location>
         </Dept>
    </Employee>
    I want to create a view of DeptNo nodes such that I can use standard SQL to query. Since it's possible to have multiple of such nodes, per oracle tutorial a function needs to be created that will return a TableType (I created a tabletype that contains rows of Dept2_Type object types) and I use this function when creating the DeptView:
    here is the function:
    (deptData in sys.XMLTYPE)
    return EMP2_DEPT_TABLE
    pipelined is
    DEPTS sys.XMLTYPE;
    DEPT sys.XMLTYPE;
    DeptNo number;
    I binary_integer := 1;
    DeptName varchar2(40);
    Location varchar2(40);
    begin
    DEPTS := deptData.extract('//Dept');
    loop
    DEPT:=DEPTS.extract('/Dept['||I||']');
    exit when DEPT is null;
    DeptName := DEPT.extract('/Dept/DeptName/text()').getStringVal;
    DeptNo := DEPT.extract('/Dept/DeptNo/text()').getNumberVal;
    Location := DEPT.extract('/Dept/Location/text()').getStringVal;
    pipe row (DEPT2_T(null,DeptNo,DeptName,Location));
    I := I + 1;
    end loop;
    return;
    end;
    here is the code for the view:
    select
    sys.xmlType.getNumberVal(sys.xmlType.extract(E.EMPDATA,'/Employee/EmployeeId/text()'))
    "EId",
    D.DeptNo,D.DName,D.Loc
    from EMP2 E, table(GET_EMP2_DEPTS(E.EMPDATA)) D
    when I query the DeptView I get no records back eventhough there is a record.
    Also if I create a slightly different view of dept:
    select
    sys.xmlType.getNumberVal(sys.xmlType.extract(E.EMPDATA,'/Employee/Dept/DeptNo/text()'))
    "DeptNo",
    sys.xmlType.getStringVal(sys.xmlType.extract(E.EMPDATA,'/Employee/Dept/DeptName/text()'))
    "DeptName",
    sys.xmlType.getStringVal(sys.xmlType.extract(E.EMPDATA,'/Employee/Dept/Location/text()'))
    "Location",
    sys.xmlType.getNumberVal(sys.xmlType.extract(E.EMPDATA,'/Employee/EmployeeId/text()'))
    "EmployeeID"
    from EMP2 E
    and query thais view I get back one record where DeptName and Location columns have the 2 values in one tuple:
    'Dept Name 1 Dept Name 2' 'Location 1Location 2'
    what I want to see is 2 records returned:
    Dept Name 1 Location 1
    Dept Name 2 Location 2
    has anyone tried this before?
    thanks in advance

    Hi Joe,
    I had a quick look into the files you send me.
    The problem is caused by the definition of the return value for the function.
    You used:
    CREATE Function Batch_Tanks_List (ID INTEGER)
        RETURNS VARCHAR AS
    VAR
        Tanks    Varchar (100) ;
        BatchTank Varchar (100) ;
    TRY
    RETURN ltrim (Tanks, ', ') ;
    create or replace view test as select batch_tanks_list (id) namel from batches
    Because of the unknown size of the return value the view cannot be created.
    If you use CHAR(100) as return value it should work w/o problems:
    CREATE Function Batch_Tanks_List (ID INTEGER)
        RETURNS CHAR(100) AS
    VAR
        Tanks    Varchar (100) ;
        BatchTank Varchar (100) ;
    TRY
    RETURN ltrim (Tanks, ', ') ;
    create or replace view test as select batch_tanks_list (id) namel from batches
    I believe that currently the feature of variable length return values to be used in views is not yet supported, but I would need to check this further.
    KR Lars

  • Syntax error while creating Calculation view script based

    Hi Folks,
    I'm creating Calc view based on script and drafted a simple code but I'm getting syntax error.
    Its just fetching few coloumns from two tables products and purchaseorderitem.
    /********* Begin Procedure Script ************/
    BEGIN
      var_out = select productid , category, nameid, currency, grossamount, quantity
      FROM sap.hana.democontent.epm.data.products AS P , sap.hana.democontent.epm.data.purchaseorderitem AS B
      where P.productid = B.productid;
    END /********* End Procedure Script ************/
    Could you pls take a look and let me know what wrong I'm doing?
    Error logs are:-
    sap.hana..package.project.folder.mytest.CALCSCRIPTVIEWInternal deployment of object failed;Repository: Encountered an error in repository runtime extension;Internal Error:Deploy Calculation View: SQL: sql syntax error: incorrect syntax near "democontent": line 5 col 18 (at pos 439)nSet Schema DDL statement: set schema "SYSTEM"nType DDL: create type "_SYS_BIC"."sap.hana..package.project.folder.mytest/CALCSCRIPTVIEW/proc/tabletype/VAR_OUT" as table ("PRODUCTID" NVARCHAR(10), "CATEGORY" NVARCHAR(2), "NAMEID" NVARCHAR(10), "CURRENCY" NVARCHAR(5), "GROSSAMOUNT" DECIMAL(15,2), "QUANITYT" DECIMAL(13,3))nProcedure DDL: create procedure "_SYS_BIC"."sap.hana.package.project.folder.mytest/CALCSCRIPTVIEW/proc" ( OUT var_out "_SYS_BIC"."sap.hana.package.project.folder.mytest/CALCSCRIPTVIEW/proc/tabletype/VAR_OUT" ) language sqlscript sql security definer reads sql data as n /********* Begin Procedure Script ************/ n BEGIN n t var_out = select productid , category, nameid, currency, grossamount, quantityn t FROM sap.hana.democontent.epm.data.products AS P , sap.hana.democontent.epm.data.purchaseorderitem AS Bn t where P.productid = B.productid;nnEND /********* End Procedure Script ************/n

    Hi Rubane,
    I don't have EPM installed here but based on this Table User Defined Functions( Table UDF ) in HANA  you are not properly defining the source table.
    In your case missing 1) schema of EPM, 2) not using double quotes, 3) separation of package and view, 4) missing camel case on purchaseOrderItem:
    FROM sap.hana.democontent.epm.data.products AS P , sap.hana.democontent.epm.data.purchaseorderitem AS B
    On blog:
    from "SAP_HANA_EPM_DEMO"."sap.hana.democontent.epm.data::businessPartner" as a
    SAP_HANA_EPM_DEMO is the schema
    sap.hana.democontent.epm.data is the package
    businessPartner is the view
    Start simple... before the seletion try it out on Studio SQL.
    Regards, Fernando Da Rós

  • Creating View based on Current and previous data from same table

    I am trying to create a view based on a table called “my_companies”. The table has following columns: “company_id”, “start_date”, “product_type_code”, “partner_id”
    The main purpose of this view is to obtain previous company_id’s associated with a particular “partner_id“and “product_type_code”. So basically, I’m looking to create an extra column, say “prev_company_id” in the view along with all the other columns. The “previous” data can be obtained depending on the “start_date”. I’m not able to write a query successfully to do this.
    Can anyone help? Thanks in advance.

    Hi,
    Whenver you have a question, it helps to post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data
    (4) Your best attempt so far
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    Formatted tabular output is okay for (3). Type before and after the tabular text, to preserve spacing.  The sample results should include any special cases that you foresee, such as one company having many previous companies, or vice-versa.
    It sounds like might need a +self-join+, where you have two copies of the same table, as if the current companies were in one table and the previous companies were in another, even though they are all actually in the same table.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Create a view in the database based off a jdbc connection

    I have some data in a DB2 database that I would like to union with a table in an Oracle Database in the Oracle Database.
    Can I create a jdbc connection in the Oracle database that points to the DB2 database and then create a view based off of the jdbc connection?
    I've never done anything like this , but if this a no brainer please just post a link or something that points me in the right direction thanks...
    I've searched...

    Mark,
    I was going to suggest the same thing as Jan did when she answered this question that you also posted to the Union DB2 and Oracle data in a view and display in a form using jdbc? forum.
    Good Luck,
    Avi.

  • Problem in CR XI returning Views with PUBLIC synonyms

    I am having problem in CR XI returning Views with PUBLIC synonym.
    I can see the tables and stored procedures with PUBLIC synonym but not VIEWS.
    This is a simple View that has a PUBLIC synonym to it. I have granted the user SELECT access to the underlying Views.
    I checked the boxes in Report > Options for all the combinations possible one by one but to no avail.
    I connect CR to the instance as a specific user , password. But when I go to Views (and Tables) there is nothing visible.
    I tried PRIVATE synonyms and when I go to Views (and Tables) the views are visible, but now the Fields are not visible.
    In SQL+ and Oracle SQL Developer connected as the same user , password everything looks ok.
    Any help will be appreciated.

    Hi Wayne,
    Sorry for the delay. Not sure where this post came from.... must have been transferred from another forum.
    R1 is no longer support nor are updates available. You can upgrade to CR Xi R2 for free, it's end of life now also but has all of the latest patches included.
    Install with your XI R1 keycode and then test again.
    http://downloads.businessobjects.com/akdlm/crystalreports/crxir2_sp4_full_bld_0-20008684.exe
    http://downloads.businessobjects.com/akdlm/crystalreports/CRYSTALREPORTS06_0-20008684.EXE
    Thank you
    Don

Maybe you are looking for