Grant select on table to user

IN A SCHEMA TEST1 THERE ARE 200 PLUS TABLES AND VIEWS.NOW I WANT TO GRANT SELECT ON TABLES AND VIEWS TO TEST2 USER.HOW CAN I GRANT SELECT ON THOSE TABLES AND VIEWS IN BULK INSTED OF GRANTING INDIVIDUALLY.
Any idea?
Thankx...
Sorry for suing cap.letters....

That works providing the grantee doesn't want to be able to build stored procedures or (more likely) views on the granted tables...
SQL> conn u1/u1
Connected.
SQL> create role select_u1
  2  /
Role created.
SQL> grant select on t1 to select_u1
  2  /
Grant succeeded.
SQL> grant select_u1 to u3
  2  /
Grant succeeded.
SQL> conn u3/u3
Connected.
SQL> select * from u1.t1
  2  /
      COL1
         1
SQL> create view my_view as
  2  select * from u1.t1
  3  /
select * from u1.t1
ERROR at line 2:
ORA-01031: insufficient privileges
SQL> As it happens, we know from the OP's other thread that they want a read only user, so perhaps the role will suffice. But they still need to grant selects on 200 objects to the role, so the automation will still come in handy :)
Cheers, APC

Similar Messages

  • Making new user & granting select any table privilages

    I want to make a new user account who have only select all tables privilages, i am trying this but it not working, please make correction...
    SQL> create user aaa identified aaabbbccc;
    SQL> grant connect, select any table to aaa;
    But its not working.......Plz forward the right commands...

    When you create new user, it has PUBLIC role privilegesPeter, what do you mean exactly ? The following is an extract from 10.2 documentation :
    When you create a user with the CREATE USER statement, the user's privilege domain is empty. To log on to Oracle Database, a user must have the CREATE SESSION system privilege. Therefore, after creating a user, you should grant the user at least the CREATE SESSION system privilege.

  • Granting select, insert to an user

    Hello,
    i have a user, 'roger', with dba privileges. i created a view(named 'vw_absente'), and then a user, 'user1', to which i granted connect, resource, and then select, insert on vw_absente. but when i log off, and i log in with that user, i wanna select * from vw_absence, but i got that 'Table or view does not exist'.
    However, i wanna in Forms, if that user logs on, when creating a new data block, to show only the tables and views the current user has privileges to. in my case i don't see any table or view when i log in with the 'user1' user.
    What i did wrong?
    so i wanna that user to update only some columns from a table (that's why i created the view and granted the select and insert privileges on that view, to 'user1' user).
    Please help me
    Thanks

    The public synonym doesn't belong to your schema. You only see the objects which belongs to your schema. You didn't see the dual table in the selection as the public synonym doesn't belong to your schema. There's a public synonym for the dual table. The synonym belongs to the public schema. You can access the dual table via sys.dual or simply use the public synonym dual for sys.dual as there's a synonym which belongs to the public schma where your user belongs to...
    just a test:
    SQL> conn sys/oracle as sysdba
    Connected.
    SQL> create user testsyn identified by testsyn;
    User created.
    SQL> create table test (id number);
    Table created.
    SQL> grant all on test to public;
    Grant succeeded.
    SQL> create public synonym test for sys.test;
    Synonym created.
    SQL> grant connect, resource to testsyn;
    Grant succeeded.
    SQL> conn testsyn/testsyn
    Connected.
    SQL> select * from user_objects where object_name = 'TEST';
    no rows selected
    SQL> select * from test;
    no rows selectedI can select on test altough in my schema there's no test object...
    Also look at the dual table (user testsyn):
    SQL> select * from dual;
    D
    X
    SQL> select * from user_objects where object_name = 'DUAL';
    no rows selected
    SQL>  select * from all_synonyms where synonym_name = 'DUAL';
    OWNER                      SYNONYM_NAME                TABLE_OWNER          TABLE_NAME               DB_LINK
    PUBLIC                      DUAL                     SYS               DUALand the next:
    SQL> conn sys/oracle as sysdba   
    Connected.
    SQL> insert into test(id) values (1);
    1 row created.
    SQL> insert into test(id) values (2);       
    1 row created.
    SQL> insert into test(id) values (3);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from test;
         ID
          1
          2
          3
    SQL> grant create table to testsyn;
    Grant succeeded.
    SQL> conn testsyn/testsyn
    Connected.
    SQL> select * from test;
         ID
          1
          2
          3
    SQL> create table test (id number);
    Table created.
    SQL> select * from test;
    no rows selectedThe first, I insert into the table, and as it is granted to the public schema the user testsyn can see te records in the test table where public test synonym points to. then, I created a test table in the testsyn schema, and as there is a more specific test table this one is used...
    and one last sample:
    SQL> conn sys/oracle as sysdba
    Connected.
    SQL> create user testsyn2 identified by testsyn2;
    User created.
    SQL> grant connect, resource to testsyn2;
    Grant succeeded.
    SQL> conn testsyn2/testsyn2
    Connected.
    SQL> select * from test;
         ID
          1
          2
          3
    SQL> conn sys/oracle as sysdba
    Connected.
    SQL> create synonym testsyn2.test for testsyn.test;
    Synonym created.
    SQL> conn testsyn/testsyn
    Connected.
    SQL> grant select on test to testsyn2;
    Grant succeeded.
    SQL> conn testsyn2/testsyn2
    Connected.
    SQL> select * from test;
    no rows selected
    SQL> So, quick answer to your question: you only see objects in your own schema, that's why you didn't see your object although you created a public synonym ;).
    regards

  • Grant select sequence to other users

    Hi all,
    Assume: I have a user "A" who have table name "test" and sequence name "test_seq". How can the user "B" able to select on the sequence "test_seq" of user A, by this command below:
    connect B/password
    SELECT test_seq.nextval from dual;
    Thanks,

    A must run:
    GRANT SELECT ON test_seq TO b;B must run:
    CREATE SYNONYM test_seq FOR a.test_seq;Message was edited by:
    Pierre Forstmann

  • Granting SELECT on Tables

    Friends
    What'd be the simplest way to give an user access to SELECT a table but excluding from it one specific column?
    Tks!

    Hello KeenOnOracle
    Yes.
    And it is recommended that you do not use the star-operator for creating views.
    Because it is possible to create a view with this "CREATE VIEW view_name AS SELECT * FROM table_name;" -> But it is only in special cases recommended... (Architecture-View)
    But because you have to exclude a column so in your case it is no problem. You have to list up your columns in the create command so if you change the structure of the table you have to change your view definition too.

  • Grant select privilege to specific columns on a table to user in Oracle 9i

    Can anyone tell me how to grant select privilege to a user for specific columns in a table?
    I have tried the following statement
    GRANT SELECT (EMP_ID) ON EMP TO USER1
    But it's not working and I am getting this error "Missing ON Keyword".
    Please anyone tell me how to grant select privilege for specific columns.
    Edited by: 899045 on Nov 24, 2011 7:03 AM

    899045 wrote:
    Can anyone tell me how to grant select privilege to a user for specific columns in a table?
    I have tried the following statement
    GRANT SELECT (EMP_ID) ON EMP TO USER1
    But it's not working and I am getting this error "Missing ON Keyword".
    Please anyone tell me how to grant select privilege for specific columns.
    Edited by: 899045 on Nov 24, 2011 7:03 AMFrom the 9.2 SQL Reference manual, found at tahiti.oracle.com (http://docs.oracle.com/cd/B10501_01/server.920/a96540/statements_912a.htm#2062456)
    *"You can specify columns only when granting the INSERT, REFERENCES, or UPDATE privilege. "*

  • Granting SELECT to user on VIEW with FULL OUTER JOIN fails?

    I have a quandary.
    Using Oracle 9i, I have created a simple view. When I perform a count on it, rows are returned.
    However, when I grant SELECT access to another user, they can't see the VIEW. The VIEW has a FULL OUTER JOIN operation in it.
    When I do the same thing using a regular join, it works.
    Any ideas why, please?
    SQL> conn ifsinfo/******@DB
    Connected.
    SQL> ed
    Wrote file afiedt.buf
      1  create view mctest3 as
      2  select
      3   vc.idcus ,
      4   ci.customer_id
      5  from
      6   ifsapp.vmo_company vc
      7  full outer join
      8   ifsapp.customer_info ci
      9  on
    10*  vc.custno = ci.customer_id
    SQL> /
    View created.
    SQL> select count(*) from mctest3;
      COUNT(*)
         73994
    SQL> GRANT SELECT ON MCTEST3 TO IFSAPP WITH GRANT OPTION;
    Grant succeeded.
    SQL> CONN IFSAPP/******@DB
    Connected.
    SQL> select count(*) from IFSINFO.MCTEST3;
    select count(*) from IFSINFO.MCTEST3
    ERROR at line 1:
    ORA-00942: table or view does not existbut with regular join:
    SQL> conn ifsinfo/******@DB
    Connected.
    SQL> create view mctest4 as
      2    select
      3     vc.idcus ,
      4     ci.customer_id
      5    from
      6     ifsapp.vmo_company vc, ifsapp.customer_info ci
      7    where vc.custno = ci.customer_id;
    View created.
    SQL> select count(*) from mctest4;
      COUNT(*)
         44269
    SQL> GRANT SELECT ON MCTEST4 TO IFSAPP WITH GRANT OPTION;
    Grant succeeded.
    SQL> conn ifsapp/******@DB
    Connected.
    SQL> select count(*) from IFSINFO.MCTEST4;
      COUNT(*)
         44269

    Hi,
    >>SQL> conn ifsinfo/******@DB
    Connected.
    SQL> ed
    Wrote file afiedt.buf
    1 create view mctest3 as
    2 select
    3 vc.idcus ,
    4 ci.customer_id
    5 from
    6 ifsapp.vmo_company vc
    7 full outer join
    8 ifsapp.customer_info ci
    9 on
    10* vc.custno = ci.customer_id
    SQL> /
    According to Note:244315.1, it is not possible to make a FULL OUTER JOIN on views owned by another user at the 9i version of Oracle. As above, do not use FULL OUTER JOIN on views owned by another user. Try to use outer join operator (+), and/or UNIONS instead.
    Cheers

  • How to GRANT SELECT on all the tables in 1 go?

    Hi
    I have many tables (close to 200) in my Schema. I want to grant SELECT ON ALL TABLES to another user. How do I achieve this in one go?
    Thanking you in advance,
    ...

    Although Justin has given a wonderful answer. You might also review the following threads;
    Grant select on a schema
    Re: Grant select on a schema
    grant select on
    grant select  on
    grant select on tables
    Re: grant select on tables
    Adith

  • GRANT SELECT to TEMP(by procedure)..... ALL tables and views of OWNER....

    hi ,
    I want to privelege only Grant SELECT ALL tables,views....
    I have written A procedure.....given below....
    CREATE OR REPLACE PROCEDURE GRANT_SELECT_ALL_PROC
    IS
    l_obj VARCHAR2(60);
    l_obj_type VARCHAR2(60);
    CURSOR Cur_Obj IS
    SELECT OBJECT_NAME,OBJECT_TYPE
    FROM USER_OBJECTS
    WHERE USER ='OWNER';
    BEGIN
    For i in Cur_Obj Loop
    l_obj := i.OBJECT_NAME;
    l_obj_type := i.OBJECT_TYPE;
    IF l_obj_type IN ('TABLE','VIEW')
    THEN
    EXECUTE IMMEDIATE 'GRANT SELECT ON' || l_obj ||'TO TEMP’;
    ELSIF l_obj_type IN('FUNCTION','PROCEDURE','PACKAGE') THEN
    EXECUTE IMMEDIATE 'GRANT EXECUTE ON'|| l_obj ||'TO TEMP’;
    END IF;
    END LOOP;
    END GRANT_SELECT_ALL_PROC;
    procedure is working fine.....
    OWNER there are some table and views......
    But After creation of User name TEMp....
    When I m giving GRANT SELECT to TEMP(by procedure)..... ALL tables and views of OWNER....
    when I coonecte to TEMP...
    Not getting table,view List...
    not even data of table or Views.....
    can anybdy help me.......advance thanx ...
    sanjay

    hi ,
    I want to privelege only Grant SELECT ALL
    tables,views....
    have written A procedure.....given below....
    CREATE OR REPLACE PROCEDURE GRANT_SELECT_ALL_PROC
    IS
    l_obj VARCHAR2(60);
    l_obj_type VARCHAR2(60);
    CURSOR Cur_Obj IS
    SELECT OBJECT_NAME,OBJECT_TYPE
    FROM USER_OBJECTS
    WHERE USER ='OWNER';
    BEGIN
    For i in Cur_Obj Loop
    l_obj := i.OBJECT_NAME;
    l_obj_type := i.OBJECT_TYPE;
    IF l_obj_type IN ('TABLE','VIEW')
    THEN
    EXECUTE IMMEDIATE 'GRANT SELECT ON' || l_obj ||'TO
    TEMP’;
    ELSIF l_obj_type IN('FUNCTION','PROCEDURE','PACKAGE')
    THEN
    EXECUTE IMMEDIATE 'GRANT EXECUTE ON'|| l_obj ||'TO
    TEMP’;
    END IF;
    END LOOP;
    END GRANT_SELECT_ALL_PROC;
    procedure is working fine.....
    OWNER there are some table and views......
    But After creation of User name TEMp....
    When I m giving GRANT SELECT to TEMP(by
    procedure)..... ALL tables and views of OWNER....
    when I coonecte to TEMP...
    Not getting table,view List...
    not even data of table or Views.....
    can anybdy help me.......advance thanx ...
    sanjayQuery SELECT * FROM USER_TAB_PRIVS_MADE from the user from which you are executing the procedure
    and Query SELECT * FROM USER_TAB_PRIVS_RECD from the TEMP user.

  • GRANT SELECT ON ALL TABLES

    Is there a direct SQL to grant select on all tables in the schema for a user? Or do we need to write a PLSQL for this?
    Also, if a new table T1 is created or existing table T2 is dropped and recreated after granting the select all privilege, will the user have access to T1 and T2?
    thanks

    Is there a direct SQL to grant select on all tables
    in the schema for a user? Or do we need to write a
    PLSQL for this?There is no privilege that would give user A access to all the tables in schema B. You would need to grant access to each object, which can certainly be done via dynamic SQL in PL/SQL.
    There is a privilege SELECT ANY TABLE which allows the user to query any table in the system, but this is generally very dangerous and probably not something you would want to give a normal user.
    Also, if a new table T1 is created or existing table
    T2 is dropped and recreated after granting the select
    all privilege, will the user have access to T1 and
    T2?Unless you grant SELECT ANY TABLE, you would need to explicitly grant A access to any new tables created in schema B (or to tables after they are dropped and re-created). Potentially, you could create a DDL trigger that submitted a job that would, in turn, make the grant whenever a new table was created in schema B.
    Justin

  • Set Grant Permission to table in Access Database

    Hello All,
    How to set grant permission in Access 2003 Database. I am using Microsoft ACE OLEDB 12.0 Connection String, Using System.Data.OleDb Component and want to set Grant DELETE, INSERT, PROCEDURE, SELECT, UPDATE ON MSysObjects TO Admin
    Best Regard
    Xan To

    Hello Kevin And Paul
    I have tried what you all say, but I get an error like this
    this my code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim Builder As New OleDb.OleDbConnectionStringBuilder
    Try
    With Builder
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .DataSource = "C:\Users\Xan To\Desktop\Test.mdb"
    End With
    'Using cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Xan To\Desktop\Test.mdb; Jet OLEDB:System Database=system.mdw;")
    Using cn As New OleDb.OleDbConnection
    With cn
    .ConnectionString = Builder.ConnectionString
    End With
    Using cmd As New OleDb.OleDbCommand
    With cmd
    .Connection = cn
    .CommandText = "GRANT SELECT ON TABLE MSysObjects TO Admin"
    End With
    cn.Open()
    cmd.ExecuteNonQuery()
    End Using
    End Using
    Catch ex As Exception
    MessageBox.Show(ex.ToString)
    End Try
    End Sub

  • Grant read only to one user

    Hello everyone,
    I'd gone through unlimited forums and blogs but not got any proper solution and is getting confused as I'm not good in sql.
    I had created a db user.
    I need grant it following privileges same as read only apps user:-
    (1) It can only select all tables except dba related tables, views etc.
    (2) It can only select any table of any user
    (3) It can only select any function, procedures and every custom objects.
    (4) it can select any table without prefixing apps. before table.
    Step by step instructions required with sql statements.

    Hi,
    Richa wrote:
    Hello everyone,
    I'd gone through unlimited forums and blogs but not got any proper solution and is getting confused as I'm not good in sql.
    I had created a db user.
    I need grant it following privileges same as read only apps user:-
    (1) It can only select all tables except dba related tables, views etc.
    (2) It can only select any table of any userThe SELECT ANY TABLE system privilege enables a user to select from any table including dba related tables and views. If you want to exclude them, then you have to give SELECT privileges on all the other tables, one at a time, and remember to do it for new tables as they are created.
    (3) It can only select any function, procedures and every custom objects.The EXECUTE ANY PROCEDURE system privilege does that.
    (4) it can select any table without prefixing apps. before table.Don't be sill. That's like saying "it can select from any table without giving the table name", or "without typing anything".
    You might reduce how often you have to qualify the table name with the schema name by using "ALTER SESSION SET CURRENT_SCHEMA = schema_name;".
    Step by step instructions required with sql statements.To give the privileges mentioned in (1), (2) and (3) to user FUBAR, log in as SYSTEM and say
    GRANT  SELECT ANY TABLE          TO fubar;
    GRANT  EXECUTE ANY PROCEDURE     TO fubar;

  • Granting select privileges

    I want to grant select privileges on all tables and views belonging to database xyz to the user abc.
    What's the best way to do that?
    Message was edited by: Diarmuid - 11/07/07
    user580522

    I beg to differ. Of course OP can try to 'GRANT SELECT ANY TABLE'. It's just a matter of his own privileges if he succeeds or not.
    To OP: Reading about GRANT might help:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9013.htm#i2077938
    Note this part from the docs:
    To grant a system privilege, you must either have been granted the system privilege with the ADMIN OPTION or have been granted the GRANT ANY PRIVILEGE system privilege.

  • Grant SELECT on all APPS objects to Custom schema

    Hi All,
    My requirement is to GRANT SELECT privileges on all Objects from APPS schema to a custom schema say XXTEST.
    I am OK, if there are multiple privileges to be granted (i.e. separate ones for TABLES,SYNONYMS,PACKAGES).
    I basically want to refer all APPS objects from XXTEST, without any schema prefix.
    I read about GRANT SELECT ANY TABLE, and it looks like I can access any schema objects from it.
    But I would like to know if I can grant from a particular schema alone.
    Thanks.

    Kavipriya wrote:
    I came across a privilege like 'SELECT ANY DICTIONARY', from which I can access all dictionary related tables without schema prefix. So am looking for something similar for APPS objects.Problem is, something similar for APPS objects does not exist. It's simply not there. You need to grant 'ANY' privileges, which means you'll be allowing the user to all the tables in the database, which is almost certainly not what you want, or you need to do individual grants.
    As I mentioned before, you can write SQL that will generate the GRANT statements for you, so you don't need to do it yourself.
    For example:
    select 'grant select on '||owner.table_name||'to some_user;' from dba_tables where owner='APPS';And then execute the output of that query, which will be a bunch of GRANT statements.
    Hope that helps,
    -Mark

  • Grant Select,  need help fast!!!!

    heres my question, i created several tables and i want to be able to give someone else access to them. i only want them to be able to run queries, table descriptions, table data, views. i dont want them to be able to modify any of the tables. heres what i think i should type at sql prompt:
    sql> GRANT SELECT ON <table name> TO <user name>;
    is that correct?
    thanks in advance.
    danny

    Hi,
    You have created a table 'TEST'.
    If you want to give access to ALL the users and if you have DBA privilege you can create a public synonym. It can be created in the same name i.e 'TEST'
    CREATE PUBLIC SYNONYM TEST FOR TEST
    GRANT SELECT ON TEST TO PUBLIC
    If you want to give access only to ONE user and if you don't have DBA privilege then you can create private synonym. The synonym name should be different from table name . ie 'TEST1'
    CREATE SYNONYM TEST1 FOR TEST
    GRANT SELECT ON TEST1 TO <Any other User>
    Hope this will solve your problem.
    Rgds,
    Venky.

Maybe you are looking for