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
Similar Messages
-
Grant select on all table of a schema to role
Hi , is it possible to grant select on all table on a schema to a role?
To grant SELECT on all tables of the current schema to particular role or user:
SELECT 'GRANT SELECT ON '||TABLE_NAME||' TO READ_ONLY_ROLE;' COMMAND
FROM (
SELECT TABLE_NAME
FROM ALL_TABLES
WHERE OWNER = (SELECT USER FROM DUAL)
Then copy and execute the result commands, eg:
GRANT SELECT ON DEPT TO READ_ONLY_ROLE;
GRANT SELECT ON EMP TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_USERS TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_CUSTOMERS TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_ORDERS TO READ_ONLY_ROLE; -
Grant select on all tables of a schema
I need to grant select on all tables (over 200 tables) of a schema to other users. Are there any SQL syntax to do this?
Thanks!Execute the following script, modify it for your environment:
Script
Accept from_owner char prompt 'Grant from user:'
Accept to_user char prompt 'grant to user:'
set head off;
set lines 300;
set pages 0;
set termout off;
set feedback off;
set head off;
set verify off;
spool d:\temp\grant.sql
select 'grant select on &from_owner..'||
table_name||
' to &to_user;'
from dba_tables
where owner=upper('&&from_owner');
spool off;
set head on;
set pages 24;
set termout on;
set feedback on;
set head on;
@d:\temp\grant.sqlExecution example:
system@DBA> @d:\temp\grants.sql
Grant from user:scott
grant to user:ejemplo
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded. -
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 on all of views to public
How to grant select on all of views to public? Thanks in advance.
782150 wrote:
How to grant select on all of views to public? Thanks in advance.
spool doit.sql
select 'grant select on '||
owner ||
'.' ||
view_name ||
' to public;'
from dba_views;
spool offexecute doit.sql
That's how it's done. Whether or not it's wise is a different question. -
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 -
hi Friends ,i need a suggestion from you on how to
insert data to all tables on a Database "A " on Test server
Select data from all tables on a Database "A" on Production Server
where id=123
Database A is same with Structures on Test and Production also all Tables will have Id column in common.
The purpose of this insert is ,as we all know Production has the latest data and i need to push to test server on request for particular ID only ( may be weekly once or twice a week )
I have a linked server setup name "LINQ"
Example for one table is below , like wise i need a script which does for 154 tables.
Insert into ABC( id, name)---insert to test server
Select Id, name from LINQ.ProdSerevrname.databasename.ABC where id = 123
Please help me ..
ThanksWhy not use export import wizard for this if you've read access to production?
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Who granted select on a table and when?
Hi all,
We are running Oracle 10g. There are some discrepancies with a table between our production versus development environments. The table on development has additional grants and also has a synonym. My boss wants to know who had granted access to this table and when? I am not a DBA. I asked our DBA and he said he didn't think Oracle keeps track of that type of information. Is it possible to track these types of changes? For example who created synonym for this table and when? One more thing to add is that audit has not been turned on.
Thank you for your input,
SeyedSeyed_G wrote:
Hi all,
We are running Oracle 10g. There are some discrepancies with a table between our production versus development environments. The table on development has additional grants and also has a synonym. My boss wants to know who had granted access to this table and when? I am not a DBA. I asked our DBA and he said he didn't think Oracle keeps track of that type of information. Is it possible to track these types of changes? For example who created synonym for this table and when? One more thing to add is that audit has not been turned on.
Thank you for your input,
SeyedPossible only if auditing enabled. -
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
HarryYou 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. -
Select from all tables in schema
hi, i am trying to x,y from tables in a schema, getting "missing expression" error, working with oracle 11g.
declare
v_sql varchar2(4000);
v_x number;
v_y number;
v_n number;
begin
for rec in (select table_name as table_name from all_tables where table_name like '%AM_%' ORDER BY 1) loop
v_sql := 'select a.idnumber, t.x, t.y, table(sdo_util.getvertices(a.geometry)) t FROM '||rec.table_name ||' a';
EXECUTE IMMEDIATE v_sql INTO v_n, v_x, v_y;
dbms_output.put_line(v_n||v_x||v_y);
end loop;
end;hi two rows, with idnum and geometry columns...
IDNUM
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
GD8
SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(-.48230432, 51.4645609, -.47600566, 51.464582, -.47206108, 51.4645953, -.4654
6537, 51.4646174, -.46423724, 51.4646216, -.45892656, 51.4646394, -.45671873, 51
.4646468, -.45007509, 51.4646691, -.4487052, 51.4646737, -.44809122, 51.4646758,
-.44748667, 51.4646778, -.44118568, 51.4646989, -.44038184, 51.4647016, -.43534
624, 51.4647186, -.43415307, 51.4647226, -.43413338, 51.4647226, -.43410223, 51.
4647227, -.43408667, 51.4647228, -.43408688, 51.4648537, -.43408691, 51.4648694,
-.43408703, 51.4649432, -.43408705, 51.4649579, -.43408717, 51.4650319, -.4340872,
51.4650481, -.43408741, 51.465177, -.4341061, 51.4651769, -.43413411, 51.465
1768, -.43415863, 51.4651767, -.43493934, 51.4651741, -.43724392, 51.4651664, -.
4381469, 51.4651633, -.43876878, 51.4651612, -.44038073, 51.4651558, -.4409811,
51.4651538, -.44732658, 51.4651325, -.44759329, 51.4651316, -.44870078, 51.46512
79, -.45213755, 51.4651164, -.45482423, 51.4651073, -.45795448, 51.4650968, -.46
041684, 51.4650886, -.46194096, 51.4650834, -.46348669, 51.4650783, -.46492913,
51.4650734, -.46744722, 51.465065, -.47410127, 51.4650426, -.47616935, 51.465035
7, -.48152654, 51.4650177, -.48230505, 51.4650151, -.48235217, 51.4650149, -.482
35215, 51.4650018, -.48235145, 51.4645722, -.48235143, 51.4645607, -.48230432, 51.4645609))
IDNUM
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
GD4
SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(-.48497261, 51.4772685, -.48209892, 51.4772786, -.48097228, 51.4772825, -.474
22571, 51.477306, -.47275437, 51.4773112, -.46898013, 51.4773243, -.46659847, 51
.4773326, -.46535204, 51.477337, -.4624971, 51.4773469, -.46135428, 51.4773509,
-.45879869, 51.4773598, -.45693251, 51.4773663, -.45570651, 51.4773706, -.453196
56, 51.4773794, -.45006644, 51.4773903, -.44747333, 51.4773993, -.44686181, 51.4774014, -.44408948,
51.4774111, -.4389499, 51.477429, -.43830451, 51.4774313, -.
4346623, 51.477444, -.43398218, 51.4774464, -.43331459, 51.4774487, -.43326608,
51.4774489, -.43326612, 51.4775874, -.43326612, 51.4776043, -.43326616, 51.47774
86, -.43326616, 51.4777641, -.43326619, 51.4779031, -.4333147, 51.4779029, -.472
655, 51.4777657, -.47413516, 51.4777605, -.48497272, 51.4777227, -.48502579, 51.
4777226, -.48502579, 51.4777106, -.48502568, 51.4772809, -.48502568, 51.4772684,
-.48497261, 51.4772685)) -
Granting select on all objects of apps in R12
Hi All,
How can I achieve like user xxx having read only access to apps user objects in EBS R12.
Best Regards,Pls check this thread
READ-ONLY APPS Schema in EBS.
and you can also check this
http://souravpupu.blogspot.com/2011/09/how-to-create-apps-read-only-user.html
thanks -
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 -
Create user with read access for all tables SAP SID .*
Hello all,
could you please help me ? I would like to grant select privilege on all tables SAP<SID>.* for newly created user.
I have created standard database user (not exclusive).
I`m able to grant select for individual tables, but I would like to grant select for this user on all SAP<SID>
schema in simplier way
But as far as I know, the schema`s owner name must be different then schema name.
Any idea please ?
Thank you.
Pavolcreate user <user_name> identified by <password> <options>;
grant read on all tables:-
CREATE OR REPLACE PROCEDURE GRANT_SELECT AS
CURSOR ut_cur IS
SELECT table_name
FROM user_tables;
RetVal NUMBER;
sCursor INT;
sqlstr VARCHAR2(250);
BEGIN
FOR ut_rec IN user_tabs_cur;
LOOP
sqlstr := 'GRANT SELECT ON '|| ut_rec.table_name
|| ' TO <user_name>';
sCursor := dbms_sql.open_cursor;
dbms_sql.parse(sCursor,sqlstr, dbms_sql.native);
RetVal := dbms_sql.execute(sCursor);
dbms_sql.close_cursor(sCursor);
END LOOP;
END grant_select;
Edited by: varun4dba on Jan 18, 2011 4:13 PM -
User Role to view all tables?
Is there a 'role' in oracle which enables a user to read (only) all the tables (exluding sys views/tables) ?
There is no such role. You would have to create one and grant SELECT on all desired objects to it. The closest thing to what you are asking is the SELECT_ANY_TABLE privilege, but it allows a user to select any table and view in the database including those in the SYS schema. This is probably not what you want.
Kind regards,
Russ Cannon -
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 ...
sanjayhi ,
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.
Maybe you are looking for
-
Pages '08 to Microsoft Word '04
I have pages '08 and i was wondering if i could print out a document from pages from the application microsoft word '03 Is there a setting i have to change on page to do this?
-
Can I deploy ADF outside IAS & Oracle RDBMS ?
Hi all, We are exploring JDev 10g to be our standard J2EE IDE. But I am wondering whether ADF can be deployed outside IAS (e.g : Tomcat, JBoss) ? for production ? Also what If ADF on SQL Server 2000 as backends ? We need to make sure about this becau
-
Warning messages on one iWeb page
Hello iWeb practitioners, Thanks to Wyodor et al who helped me with other queries about iWeb. I have published this same site to iweb (www.saivision.ie) and am getting this warning on my directory page. Am I being hacked? How do I get rid of this? Th
-
After my MacBook Pro wakes from sleep, the trackpad movement (mouse) reveals the sign-in screen in little squares.
-
I've installed OmniFocus for the iPad and synchronised it with OmniFocus for Mac; love the software, love the features. Excellent stuff. Very highly recommended. However, since this installation I have had intermittent problems with the Home button o