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
Similar Messages
-
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;
/ -
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 replyYes 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 fetch what are all the tables used in this TR no and Package name of
Hi Friends,
I have input of Transport Request no (E070-TRKORR).
How to fetch what are all the tables used in this TR no and Package name of this Table.HI,
FYI
SELECT E071OBJECT_NAME, E070MDEVCLASS
FROM E071, E070M
WHERE TRKORR = YOU REQUEST NO. -
How to delete select data in the table control
this problem makes me headache.
I am new to labview, when a table shows some data. many rows and column. how can delete on row which I selected. the other rows are remain no change.
I really need help.thanks in advance. It is better to attach the program.my labview is 2009
Solved!
Go to Solution.Hi,
You can do it with a table control as well. Check out the attached VI. To delete a row, Run the VI, just right click the row and click "Delete Row". To get back the default values, click reinitialize.
Reards,
NitZ
(Give Kudos to Good Answers, Mark it as a Solution if your problem is Solved)
Attachments:
Untitled 3.vi 8 KB -
Grant access to all the views created in user schema to another schema
How to grant access for all the views created in own HAGGIS schema to comqdhb schema on the HAGGIS database.
Oracle Grant Privileges
===============
Object privileges assign the right to perform a particular operation on a specific object
I read that we can use select 'grant select on' ||view_name||'HAGGIS' user_views where owner='COMQDHB'
Is this right
Oracle System Privileges
===============
System privileges should be used in only cases where security isnt important,because a single grant statement could remove all security from the table
Role based security
============
Role security allows you to gather related grants into a collection-since the role is a predefined collection of privileges that are grouped together.privileges are easier to assign to users.
[http://www.dba-oracle.com/art_builder_grant_sec.htm]
can we grant select update to all the views at a time to the other schema.
Are there any other ways to secure the data other than creating users and assigning roles.
Thank you
Edited by: Trooper on Dec 23, 2008 9:24 AMI think what was suggested was that you use SQL to generate the grants on each and every view, that is, you use SQL to generate SQL where the SQL being generated is "grant select on view_name to role'"
If you users to connect to Oracle you have to create usernames for them though if the users only connect via an application the application might run just as one user and access to the application is controled via application security. The control on the application can be via Directory Services such as OID or MS Active Directory. User access to Oracle can also be controlled via OID.
To connect to Oracle you can use OS authenication (not recommended), usernames with passwords, or via Advanced Security Option which supports single sign-on products like Kebros or Oracle Internet Directory etc....
Example using SQL to generate SQL
How do I find out which users have the rights, or privileges, to access a given object ?
http://www.jlcomp.demon.co.uk/faq/privileges.html
HTH -- Mark D Powell -- -
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. -
How to find accurate number of Rows, and size of all the tables of a Schema
HI,
How to find the accurate number of Rows, and size of all the tables of a Schema ????
Thanks.SELECT t.table_name AS "Table Name",
t.num_rows AS "Rows",
t.avg_row_len AS "Avg Row Len",
Trunc((t.blocks * p.value)/1024) AS "Size KB",
t.last_analyzed AS "Last Analyzed"
FROM dba_tables t,
v$parameter p
WHERE t.owner = Decode(Upper('&1'), 'ALL', t.owner, Upper('&1'))
AND p.name = 'db_block_size'
ORDER by 4 desc nulls last;
## Gather schema stats
begin
dbms_stats.gather_schema_stats(ownname=>'SYSLOG');
end;
## Gather a particular table stats of a schema
begin
DBMS_STATS.gather_table_stats(ownname=>'syslog',tabname=>'logs');
end;
http://www.oradev.com/create_statistics.jsp
Hope this will work.
Regards
Asif Kabir
-- Mark the answer as correct/helpful -
How will get the source code of all the tables in a given schema using SQL?
Hi All,
How can we get the source code of all the tables in a given schema using SQL?
Thanks in Adv.
JunuTry something like...
set heading off
set pagesize 0
col meta_data for a96 word_wrapped
set long 100000
SELECT DBMS_METADATA.GET_DDL(object_type, object_name, owner) ||';' AS meta_data
FROM dba_objects
WHERE owner = '<SCHEMA NAME>'
AND object_type not in (<list of stuff you do not want>); -
How to generate test data for all the tables in oracle
I am planning to use plsql to generate the test data in all the tables in schema, schema name is given as input parameters, min records in master table, min records in child table. data should be consistent in the columns which are used for constraints i.e. using same column value..
planning to implement something like
execute sp_schema_data_gen (schemaname, minrecinmstrtbl, minrecsforchildtable);
schemaname = owner,
minrecinmstrtbl= minimum records to insert into each parent table,
minrecsforchildtable = minimum records to enter into each child table of a each master table;
all_tables where owner= schemaname;
all_tab_columns and all_constrains - where owner =schemaname;
using dbms_random pkg.
is anyone have better idea to do this.. is this functionality already there in oracle db?Ah, damorgan, data, test data, metadata and table-driven processes. Love the stuff!
There are two approaches you can take with this. I'll mention both and then ask which
one you think you would find most useful for your requirements.
One approach I would call the generic bottom-up approach which is the one I think you
are referring to.
This system is a generic test data generator. It isn't designed to generate data for any
particular existing table or application but is the general case solution.
Building on damorgan's advice define the basic hierarchy: table collection, tables, data; so start at the data level.
1. Identify/document the data types that you need to support. Start small (NUMBER, VARCHAR2, DATE) and add as you go along
2. For each data type identify the functionality and attributes that you need. For instance for VARCHAR2
a. min length - the minimum length to generate
b. max length - the maximum length
c. prefix - a prefix for the generated data; e.g. for an address field you might want a 'add1' prefix
d. suffix - a suffix for the generated data; see prefix
e. whether to generate NULLs
3. For NUMBER you will probably want at least precision and scale but might want minimum and maximum values or even min/max precision,
min/max scale.
4. store the attribute combinations in Oracle tables
5. build functionality for each data type that can create the range and type of data that you need. These functions should take parameters that can be used to control the attributes and the amount of data generated.
6. At the table level you will need business rules that control how the different columns of the table relate to each other. For example, for ADDRESS information your business rule might be that ADDRESS1, CITY, STATE, ZIP are required and ADDRESS2 is optional.
7. Add table-level processes, driven by the saved metadata, that can generate data at the record level by leveraging the data type functionality you have built previously.
8. Then add the metadata, business rules and functionality to control the TABLE-TO-TABLE relationships; that is, the data model. You need the same DETPNO values in the SCOTT.EMP table that exist in the SCOTT.DEPT table.
The second approach I have used more often. I would it call the top-down approach and I use
it when test data is needed for an existing system. The main use case here is to avoid
having to copy production data to QA, TEST or DEV environments.
QA people want to test with data that they are familiar with: names, companies, code values.
I've found they aren't often fond of random character strings for names of things.
The second approach I use for mature systems where there is already plenty of data to choose from.
It involves selecting subsets of data from each of the existing tables and saving that data in a
set of test tables. This data can then be used for regression testing and for automated unit testing of
existing functionality and functionality that is being developed.
QA can use data they are already familiar with and can test the application (GUI?) interface on that
data to see if they get the expected changes.
For each table to be tested (e.g. DEPT) I create two test system tables. A BEFORE table and an EXPECTED table.
1. DEPT_TEST_BEFORE
This table has all EMP table columns and a TEST_CASE column.
It holds EMP-image rows for each test case that show the row as it should look BEFORE the
test for that test case is performed.
CREATE TABLE DEPT_TEST_BEFORE
TESTCASE NUMBER,
DEPTNO NUMBER(2),
DNAME VARCHAR2(14 BYTE),
LOC VARCHAR2(13 BYTE)
2. DEPT_TEST_EXPECTED
This table also has all EMP table columns and a TEST_CASE column.
It holds EMP-image rows for each test case that show the row as it should look AFTER the
test for that test case is performed.
Each of these tables are a mirror image of the actual application table with one new column
added that contains a value representing the TESTCASE_NUMBER.
To create test case #3 identify or create the DEPT records you want to use for test case #3.
Insert these records into DEPT_TEST_BEFORE:
INSERT INTO DEPT_TEST_BEFORE
SELECT 3, D.* FROM DEPT D where DEPNO = 20
Insert records for test case #3 into DEPT_TEST_EXPECTED that show the rows as they should
look after test #3 is run. For example, if test #3 creates one new record add all the
records fro the BEFORE data set and add a new one for the new record.
When you want to run TESTCASE_ONE the process is basically (ignore for this illustration that
there is a foreign key betwee DEPT and EMP):
1. delete the records from SCOTT.DEPT that correspond to test case #3 DEPT records.
DELETE FROM DEPT
WHERE DEPTNO IN (SELECT DEPTNO FROM DEPT_TEST_BEFORE WHERE TESTCASE = 3);
2. insert the test data set records for SCOTT.DEPT for test case #3.
INSERT INTO DEPT
SELECT DEPTNO, DNAME, LOC FROM DEPT_TEST_BEFORE WHERE TESTCASE = 3;
3 perform the test.
4. compare the actual results with the expected results.
This is done by a function that compares the records in DEPT with the records
in DEPT_TEST_EXPECTED for test #3.
I usually store these results in yet another table or just report them out.
5. Report out the differences.
This second approach uses data the users (QA) are already familiar with, is scaleable and
is easy to add new data that meets business requirements.
It is also easy to automatically generate the necessary tables and test setup/breakdown
using a table-driven metadata approach. Adding a new test table is as easy as calling
a stored procedure; the procedure can generate the DDL or create the actual tables needed
for the BEFORE and AFTER snapshots.
The main disadvantage is that existing data will almost never cover the corner cases.
But you can add data for these. By corner cases I mean data that defines the limits
for a data type: a VARCHAR2(30) name field should have at least one test record that
has a name that is 30 characters long.
Which of these approaches makes the most sense for you? -
Select data from all the table names in the view
Hi,
"I have some tables with names T_SRI_MMYYYY in my database.
I created a view ,Say "Summary_View" for all the table names
with "T_SRI_%".
Now i want to select data from all the tables in the view
Summary_View.
How can i do that ? Please throw some light on the same?
Thanks and Regards
Srinivas CheboluSrinivas,
There are a couple of things that I am unsure of here.
Firstly, does your view definition say something like ...
Select ...
From "T_SRI_%"
If so, it is not valid. Oracle won't allow this.
The second thing is that your naming convention for the
tables suggests to me that each table is the same except
that they store data for different time periods. This would be
a very bad design methodology. You should have a single
table with an extra column to state what period is referred to,
although you can partition it into segments for each period if
appropriate.
Apologies if i am misinterpreting your question, but perhaps
you could post your view definition and table definitions
here. -
How to delete/drop all the tables from SQL Server Database without using Enterprise Manager?
I tried using DROP Tables, Truncate Database, Delete and many more but it is not working. I want to delete all tables using Query Analyzer, i.e. through SQL Query.
Please help me out in this concern.
Nishith ShahInformative thread indeed. Wish I saw it early enough. Managed to come up with the code below before I saw this thread.
declare @TTName Table
(TableSchemaTableName
varchar
(500),
[status] int
default 0);
with AvailableTables
(TableSchemaTableName)
as
(select
QUOTENAME(TABLE_SCHEMA)
+
+
QUOTENAME(TABLE_NAME)
from
INFORMATION_SCHEMA.TABLES)
insert into @TTName
(TableSchemaTableName)
select *
from AvailableTables
declare @TableSchemaTableName varchar
(500)
declare @sqlstatement nvarchar
(1000)
while 1=1
begin
set @sqlstatement
=
'DROP TABLE '
+ @TableSchemaTableName
exec
sp_executeSQL
@sqlstatement
print
'Dropped Table : '
+ @TableSchemaTableName
update @TTName
set [status]
= 1
where TableSchemaTableName
= @TableSchemaTableName
if
(select
count([Status])
from @TTName
where [Status]
= 0)
= 0
break
end -
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?
thanksIs 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 -
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.
Maybe you are looking for
-
RME 4.3, Inventory Collection doesn't work for 6500
I have a issue with Inventory collection for 6500 devices running IOS 12.2.33 SXI1, fails with a message, "device collection failed" From IC_Server log i could see SNMP Request timeout exception, so increased SNMP timeout to 10 under device attribut
-
Dear All, I had come across one issue. In the Purchase order print i am printing the item text and also the header text. But in this if it is having the symbol " & " then the text after the "&" symbol was not printing. After that symbol it was skippi
-
This message is popping up on our company website after I updated the software. MuseJSAssert: Error calling selector function: reference Error: Spry is not defined. When I check the validator.w3.org it is saying that the errors are being cause fro
-
How to find the Navigation in peoplesoft using SQL
Hi All , I would like to know what are the possiblilites ways to find the navigation in peoplesoft. Is it possible to find using only RUN_CONTROL_ID same like Process name , component name ? . Please provide the SQL to find the possible ways. Advance
-
Wireless Mighty Mouse Replacement
I dont know to whom I have to start begging, to actually get this done... But for the love of all that is good on this Earth, can Apple PLEASE replace my wireless mighty mouse, with a wired mighty mouse. I've only owned my iMac for a few months, ever