Grant privileges on tables in other tablespace

Hi,
If my DB instance has 2 tablespaces which belong to different users, say tablespace 1 belongs to user A and tablespace 2 belongs to user B. And I want user A to have the access/modify privileges on the tables in tablespace 2, how ?
Do I first need to GRANT alter, manage user B.tablespace 2 TO user A then GRANT all tablespace 2.tables to user A ?
Or ALTER USER user A QUOTA UNLIMITED ON  user N.tablespace 2 then GRANT all tablespace 2.tables to user A ?
Or I can just GRANT all tablespace 2.tables to user A , i.e. I do not need to grant tablespace privileges , just grant table priviledge ?

thought it would be simple to grant the access, anyways one should have system privilege to do that.
Else, as Karthick specified, we have to loop through the list of tables and grant access.
BEGIN
  FOR i IN (SELECT * FROM user_tables)
  LOOP
    EXECUTE IMMEDIATE 'GRANT SELECT,INSERT,UPDATE,DELETE ON ' || i.table_name || ' TO USERA';
  END LOOP;
END;Regards,
Prazy

Similar Messages

  • Grant Privileges on schema objects

    Hello all,
    I need to grant all privs to one user on another user all objects.
    I am not findign exact command to do so.
    eg: x have y objects.
    user z should be able to select,update, delete all x.y objects.
    Any help/insight is highly appreciated. !

    You have to grant the privileges on an object by object basis.
    You can use a bit of dynamic SQL to automate the process (note that I'm only showing the process of granting privileges on tables-- you can write similar bits of code to grant privileges on views and other types of objects as well).
    BEGIN
      FOR i IN (SELECT * FROM dba_tables where owner = 'X')
      LOOP
        EXECUTE IMMEDIATE 'grant select, update, delete on x.' || i.table_name || ' to z';
      END LOOP;
    END;If Z does not need the privileges granted directly, you would probably be better off creating a role, granting the privileges to the role, and then granting the role to Z. That will make it easier in the future if you need to create another user that has the same privileges as Z.
    Justin
    Edited by: Justin Cave on Oct 15, 2012 11:50 AM

  • Insufficient privileges/can not grant to create tables

    I have just created database..
    Connected as SYS I tried to Create user/schema as following:
    CREATE USER "xsales" PROFILE "DEFAULT" IDENTIFIED BY "*******" ACCOUNT UNLOCK
    GRANT "CONNECT" TO "ABDO"
    Trying to create tables I recieved:
    Failed to commit: ORA-01950: no privileges on tablespace 'USERS'
    Then I tried to grant CREATE ANY TABLES to the user xsales to enable it to
    run the script of create tables,but I recieved
    ORA-01917: user or role 'abdo' does not exist
    although I connected with xsales succefully
    Can anyone help?

    the user name is correct .....
    I ran the following script succefully:
    CREATE USER xsales PROFILE "DEFAULT" IDENTIFIED BY "********" ACCOUNT UNLOCK;
    GRANT "CONNECT" TO xsales;
    GRANT ALTER ANY CLUSTER TO XSALES;
    GRANT ALTER ANY DIMENSION TO XSALES;
    GRANT ALTER ANY INDEX TO XSALES;
    GRANT ALTER ANY INDEXTYPE TO XSALES;
    GRANT ALTER ANY MATERIALIZED VIEW TO XSALES;
    GRANT ALTER ANY PROCEDURE TO XSALES;
    GRANT ALTER ANY TABLE TO XSALES;
    GRANT ALTER TABLESPACE TO XSALES;
    GRANT ALTER USER TO XSALES;
    GRANT ANALYZE ANY DICTIONARY TO XSALES;
    GRANT CREATE ANY CLUSTER TO XSALES;
    GRANT CREATE ANY DIMENSION TO XSALES;
    GRANT CREATE ANY INDEX TO XSALES;
    GRANT CREATE ANY INDEXTYPE TO XSALES;
    GRANT CREATE ANY MATERIALIZED VIEW TO XSALES;
    GRANT CREATE ANY PROCEDURE TO XSALES;
    GRANT CREATE ANY TABLE TO XSALES;
    GRANT CREATE ANY VIEW TO XSALES;
    GRANT CREATE CLUSTER TO XSALES;
    GRANT CREATE DATABASE LINK TO XSALES;
    GRANT CREATE DIMENSION TO XSALES;
    GRANT CREATE INDEXTYPE TO XSALES;
    GRANT CREATE MATERIALIZED VIEW TO XSALES;
    GRANT CREATE PROCEDURE TO XSALES;
    GRANT CREATE PUBLIC DATABASE LINK TO XSALES;
    GRANT CREATE TABLE TO XSALES;
    GRANT CREATE TABLESPACE TO XSALES;
    GRANT CREATE USER TO XSALES;
    GRANT CREATE VIEW TO XSALES;
    GRANT DELETE ANY TABLE TO XSALES;
    GRANT DROP ANY CLUSTER TO XSALES;
    GRANT DROP ANY DIMENSION TO XSALES;
    GRANT DROP ANY INDEX TO XSALES;
    GRANT DROP ANY INDEXTYPE TO XSALES;
    GRANT DROP ANY MATERIALIZED VIEW TO XSALES;
    GRANT DROP ANY PROCEDURE TO XSALES;
    GRANT DROP ANY TABLE TO XSALES;
    GRANT DROP ANY VIEW TO XSALES;
    GRANT DROP PUBLIC DATABASE LINK TO XSALES;
    GRANT DROP TABLESPACE TO XSALES;
    GRANT DROP USER TO XSALES;
    GRANT EXECUTE ANY INDEXTYPE TO XSALES;
    GRANT EXECUTE ANY PROCEDURE TO XSALES;
    GRANT EXPORT FULL DATABASE TO XSALES;
    GRANT GLOBAL QUERY REWRITE TO XSALES;
    GRANT GRANT ANY OBJECT PRIVILEGE TO XSALES;
    GRANT GRANT ANY PRIVILEGE TO XSALES;
    GRANT IMPORT FULL DATABASE TO XSALES;
    GRANT INSERT ANY TABLE TO XSALES;
    GRANT LOCK ANY TABLE TO XSALES;
    GRANT MANAGE SCHEDULER TO XSALES;
    GRANT MANAGE TABLESPACE TO XSALES;
    GRANT QUERY REWRITE TO XSALES;
    GRANT SELECT ANY DICTIONARY TO XSALES;
    GRANT SELECT ANY TABLE TO XSALES;
    GRANT SELECT ANY TRANSACTION TO XSALES;
    GRANT SYSDBA TO XSALES;
    GRANT CREATE SESSION TO XSALES;
    GRANT UPDATE ANY TABLE TO XSALES;
    Then I logged as XSALES to try to CREATE TABLES, still I got:
    SQL> CONN XSALES/**********@ORACLE
    Connected.
    SQL> CREATE TABLE PROD(ID number(6));
    CREATE TABLE PROD(ID number(6))
    ERROR at line 1:
    ORA-01950: no privileges on tablespace 'USERS'
    How I can solve that?

  • 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....

  • How to grant privileges on all the tables in a schema

    Hi All,
    Can you tell me how to grant privileges on all the tables of a schema A
    to schema B.
    For Example:
    There are 200 tables in schema A, I wanted to grant select privilege on all the tables of a scheme A to schema B.
    Thanks in advance.

    note that USER is the user that will have the select priviledge
    the procedure includes views as well
    CREATE OR REPLACE PROCEDURE GRANT_ACCESS_ON_USER IS
    CURSOR c1 is select table_name from user_tables;
    CURSOR c2 is select view_name from user_views;
    tablename user_tables.TABLE_NAME%TYPE;
    viewname user_views.VIEW_NAME%TYPE;
    BEGIN
    tmpVar := 0;
    OPEN c1;
    loop
         fetch c1 into tablename;
         EXIT WHEN c1%NOTFOUND;
         EXECUTE IMMEDIATE 'GRANT SELECT on '||tablename ||' to USER';
    end loop ;
    close c1;
    OPEN c2;
    loop
         fetch c2 into viewname;
         EXIT WHEN c2%NOTFOUND;
         EXECUTE IMMEDIATE 'GRANT SELECT on '||viewname ||' to USER';
    end loop ;
    close c2;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END;
    /

  • Privilege for truncating a table of other schema

    Hi friends
    I need to truncate a table of other schema. What privilege the other user has to give to carry out it.
    Thanks
    Edited by: user12892846 on 01-abr-2010 15:59

    DROP ANY TABLEWhile technically correct, above is somewhat dangerous because every schema could be impacted; even SYS.
    Assume SCHEMA_A owns TABLE_A & procedure below.
    CREATE & REPLACE PROCEDURE TRUNCATE_TABLE_A
    AS
    BEGIN
    EXECUTE IMMEDIATE 'TRUNCATE TABLE TABLE_A';
    END TRUNCATE_TABLE_A;
    GRANT EXECUTE ON TRUNCATE_TABLE_A TO SCHEMA_B;
    By doing as above SCHEMA_A can control who & which table(s) can be impacted (in is own schema only).
    Edited by: sb92075 on Apr 1, 2010 7:06 PM

  • ORACLE - How to GRANT privilegies on ALL the tables belonging to a schema

    Is there a way to grant to a user the same privilegies on ALL the tables belonging to the same schema, so that, in case a new table is created afterwards, the grant is automatically given ?
    Thanks in adance for any reply

    Yes of course ! Just do the same as Oracle Applications: an end user has no Oracle account, the application code connects with the Oracle account that is the schema owner:
    no more grant needed ... That's a joke but it's also true ! In this case, your application must implement its own security (password management, audit, privileges) and you will not be able to use Oracle privileges, auditing and advanced security features ... just like Oracle Applications.
    The above answers are of course correct. You can also create an Oracle role that you can grant to the Oracle users and grant the privileges to this role everytime a new table is created to avoid granting privileges for each new object to each user.

  • How to restrict a schema owner from granting privileges to other users.

    How can we restrict a schema owner from granting privileges to other users on his objects (e.g. tables). Lets say we have user called XYZ and he has tables in his schema TAB1, TAB2 an TAB3. How can we restrict user XYZ from granting privileges on TAB1, TAB2 and TAB3 to other users in the database. Is it possible in Oracle 10g R2? Any indirect or direct way to achieve this? Please help on this.
    Thanks,
    Manohar

    Whenever someone is trying to prevent an object owner from doing something, that's generally a sign of a deeper problem. In a production database, the object owner shouldn't generally have CREATE SESSION privileges, so the user shouldn't be able to log in, which would prevent the user from issuing any grants.
    As a general rule, you cannot stop an object owner from granting privileges on the objects it owns. You can work around this by creating a database-level DDL trigger that throws an exception if the user issuing the statement is XYZ and the DDL is a GRANT. But long term, you probably want to get to the root of the problem.
    Justin
    Edited by: Justin Cave on Nov 6, 2008 9:52 PM
    Enrique beat me to it.

  • Grant privileges  to new user + few tables

    Hi all. How can I give my new user all privileges for inserting deleting records in some tables...
    CREATE USER user1 IDENTIFIED BY user1

    May be it will be better to make nobody the owner of the tables?It's definitely a good idea to make somebody else the owner of the table rather than SYSTEM... you shouldn't really be putting your own objects in the SYSTEM schema anyway if you can help it.
    Whether NOBODY is the best schema to use depends on what you want the table for. If this is just a test system you are playing about with then it doesn't really matter... but if you are trying to put together a proper development/test system with a plan to move into a production environment then think through what you want (and whether NOBODY is the best name for your application schema).
    Saying that, if this is just a database you are 'playing' with to learn some Oracle then you might want to look at granting system privileges rather than object privileges.
    GRANT SELECT ANY TABLE TO ALEX;
    Will let ALEX select form any table (other than the data dictionary).
    Again, though, a word of caution - if you intend to put this into a 'real' system (rather than just one you are learning on) then think it through and only grant what you need. If you go for the 'easy' system privilege now you'll find you'll always be stuck with it because you'll never be 100% certain that you can revoke it without affecting your application.

  • GRANT syntax : Grant SELECT privileges on tables to a User on a Remote DB

    Hi
    I am having two databases: DEV1 and DEV2. DEV1 is my source database and DEV2 is target database. There is a table in Schema A on Dev1. I have created a PUBLIC DBLINK "TESTDBLINK" in Schema B on DEV2 that connects to Schema A on DEV1.
    Database Schema Table Machine
    DEV1 A EMP 192.168.210.10
    Database Schema Database Lik Machine
    DEV2 B TESTDBLINK 192.168.210.11
    How to grant SELECT privileges on Schema A Table EMP ( DEV1 ) to Schema B on DEV2 ? What is the syntax ?
    e.g. Log in as Schema A on DEV 1
    SQL> GRANT SELECT ON EMP TO *???????*
    Thanks for your inputs
    Harry

    You don't have to grant that table in schema A to schema B.
    Inside schema B, you can just issue a select statement like this:
    select *
    from table@db-link-to-AOracle will connect to the remote instance, using the credentials of schema A, and since A owns that table, Oracle can already access the table.

  • Grant access to all object/tables in other schemas to a user

    Is there any and simple way to grant access to all object/tables in other schemas (more than one) to a scheme/user?
    Thanks.
    Tarman.

    HI.
    grant SELECT ANY TABLE,delete any table, insert any table to user; Giving this delete,insert ANY TABLE privilege to a user can be dangerous and the use can mislead it. Its better to create a dynamic script and then grant it.
    E.g Suppose you want to give select,inert,delete,update privileges to user A on user B's object.
    sql> spool grants.sql
    sql> select 'grant select,insert,update,delete on '||owner||'.'||table_name||' to A;' from dba_tables where owner='B';
    sql>@grants.sqlHTH
    Anand

  • Grant privilege disappeared after modify versioned table

    After adding two columns to a version table using wm package, the previous grant privilege on the version table disappeared. Is it expected behavior or a bug?
    Ashley

    Ashley
    This is a bug. We have since fixed it and it will be available in the next release. For now, the workaround is that you have to grant the privilege again. Sorry for the inconvenience.
    Arun

  • How to move table from one tablespace to other tablespace?

    how to move table from one tablespace to other tablespace?

    887274 wrote:
    how to move table from one tablespace to other tablespace?
    alter table <table_name> move  tablespace <new_tablespace_name>;
    Rebuild the indexes; alter index <index_name> rebuild <new_tablespace_name> online;Example;:
    SQL> create table ttt( ID NUMBER PRimary key);
    Table created.
    SQL> insert into ttt values (1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select index_name, status  from dba_indexes where table_name='TTT';
    INDEX_NAME                 STATUS
    SYS_C0010863                 VALID
    SQL> alter table ttt move tablespace users;
    Table altered.
    SQL> select index_name, status  from dba_indexes where table_name='TTT';
    INDEX_NAME                 STATUS
    SYS_C0010863                 UNUSABLE
    SQL> alter index SYS_C0010863 rebuild tablespace users online;
    Index altered.
    SQL> select index_name, status  from dba_indexes where table_name='TTT';
    INDEX_NAME                 STATUS
    SYS_C0010863                 VALID
    SQL>

  • Grant privileges to all objects

    Oracle 11.0.1.7.0:
    When I create new user I do something like:
    create user abc identified by abc
    grant create session, create table, create views, create snapshot to abc - separate grant for each object
    grant unlimited tablespace to abc;So when I do that sometimes I forget privileges for sequences. Is there a way to give privilege in one sql to the user to let that user create table, views, session, tablespace etc.
    Edited by: user628400 on Jun 9, 2009 5:35 PM

    Is there a list of things like create table, session etc. that I can look at to determine what options I have?select distinct privilege from role_sys_privs order by 1;
    will give you a list of privileges which can be granted to role.
    is there a way to grant privileges to all different types like create table, session etc in one statement without having to type each one of them separately like grant create session, grant table?As other replied, this can be achieved by creating a role like:
    SQL> create role newrole;
    Role created.
    SQL> grant create table,query rewrite to newrole;  -- Or any privilege by above command.
    Grant succeeded.
    SQL> grant newrole to <YourUserName>;  --
    Grant succeeded.HTH
    Girish Sharma

  • Granting privilege through role not working for PL/SQL

    Version: 11.2.0.2
    In our shop, we don't grant privileges directly to a user, we grant it to a role and grant that role to the intended grantee.
    Granting privileges through a role seems to be fine with SQL Engine. But it doesn't work from PL/SQL engine.
    In the below example GLS_DEV user is granted SELECT access on SCOTT.pets table through a role called tstrole. GLS_DEV can select this table from SQL. But PL/SQL Engine doesn't seem to know this.
    Reproducing the issue:
    SQL> show user
    USER is "SCOTT"
    SQL> select * from pets;
    NAME
    PLUTO
    SQL> conn / as sysdba
    Connected.
    SQL> create user GLS_DEV identified by test1234 default tablespace TSTDATA;
    User created.
    SQL> alter user GLS_DEV quota 25m on TSTDATA;
    User altered.
    SQL> grant create session, resource to GLS_DEV;
    Grant succeeded.
    --- Granting SELECT privilege on scott.pets to tstrole and then grant this role to GLS_DEV.
    SQL> conn / as sysdba
    Connected.
    SQL>
    SQL> create role tstrole;
    Role created.
    SQL> grant select on scott.pets to tstrole;
    Grant succeeded.
    SQL> grant tstrole to GLS_DEV;
    Grant succeeded.
    SQL> conn GLS_DEV/test1234
    Connected.
    SQL>
    SQL> select * From scott.pets;
    NAME
    PLUTO
    ---- All fine till here. From SQL engine , GLS_DEV user can SELECT scott.pets table.
    --- Now , I am going to create a PL/SQL object in GLS_DEV which tries to refer scott.pets
    SQL> show user
    USER is "GLS_DEV"
    create or replace procedure my_proc
    is
    myvariable varchar2(35);
    begin
         select name into myvariable from scott.pets ;
         dbms_output.put_line(myvariable);
    end my_proc;
    Warning: Procedure created with compilation errors.
    SQL> show errors
    Errors for PROCEDURE MY_PROC:
    LINE/COL ERROR
    6/2      PL/SQL: SQL Statement ignored
    6/41     PL/SQL: ORA-01031: insufficient privileges
    SQL>
    SQL> 6
      6*    select name into myvariable from scott.pets ;
    --- PL/SQL Engine doesn't seem to know that GLS_DEV has select privilege on scott.pets indirectly granted through a role
    --- Fix
    --- Instead of granting privilege through a role, I am granting the SELECT privilege on scott.pets to GLS_DEV directly.
    --- The error goes away, I can compile and execute the procedure !!
    SQL> conn / as sysdba
    Connected.
    SQL>
    SQL> grant select on scott.pets to GLS_DEV;
    Grant succeeded.
    SQL> conn GLS_DEV/test1234
    Connected.
    SQL>
    SQL> create or replace procedure my_proc
    is
    myvariable varchar2(35);
    begin
            select name into myvariable from scott.pets ;
            dbms_output.put_line(myvariable);
    end my_proc;  2    3    4    5    6    7    8    9   10
    11  /
    Procedure created.
    SQL> set serveroutput on
    SQL> exec my_proc;
    PLUTO
    PL/SQL procedure successfully completed.Has anyone encountered the same issue ?

    You really should start your own new thread for this question instead of resurrecting an old one, but to answer your question.
    There are two things going on here. First, there are a number of aler session commands that can be used by any user regardless of what privileges they are granted. Although I do not have the entire list at hand, things like nls_date_format and current_schema are available to all users, sort of like the grants to public in the data dictionary.
    Second, when you use execute immediate, the PL/SQL engine never really sees the statement, as far as the compiler is concerned it is just a string. It is only when the string is passed to the sql engine that permissions are checked, and there roles are not enabled.
    SQL> create role t_role;
    Role created.
    SQL> grant select on ops$oracle.t to t_role;
    Grant succeeded.
    SQL> create user a identified by a default tablespace users;
    User created.
    SQL> grant create session, create procedure to a;
    Grant succeeded.
    SQL> grant t_role to a;
    Grant succeeded.
    SQL> connect a/a
    Connected.
    SQL> select * from ops$oracle.t;
            ID DESCR
             1 One
             1 Un
    SQL> create function f (p_descr in varchar2) return number as
      2     l_num number;
      3  begin
      4     select id into l_num
      5     from ops$oracle.t
      6     where descr = p_descr;
      7     return l_num;
      8  end;
      9  /
    Warning: Function created with compilation errors.
    SQL> show error
    Errors for FUNCTION F:
    LINE/COL ERROR
    4/4      PL/SQL: SQL Statement ignored
    5/20     PL/SQL: ORA-00942: table or view does not exist
    SQL> create or replace function f (p_descr in varchar2) return number as
      2     l_num number;
      3  begin
      4     execute immediate 'select id from ops$oracle.t where descr = :b1'
      5                       into l_num using p_descr;
      6     return l_num;
      7  end;
      8  /
    Function created.
    SQL> select f('One') from dual;
    select f('One') from dual
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at "A.F", line 4John

Maybe you are looking for