This question already has answers here:
How to replicate schema with the same privileges of an existing account in oracle?
(2 answers)
Closed 10 months ago.
I have a user named A having some privileges. How can I grant all privileges which A is having and grant to user B?
Thanks in advance
Get all privileges from user A
SELECT DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT','A') FROM DUAL;
SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT','A') FROM DUAL;
SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT','A') FROM DUAL;
Change the DDL commands with the user 'B' and execute.
Related
I'm new to Oracle and would like to know the way how to get more statistics in the case i'll describe below. I'm using SQL Developer.
First, I execute this:
SET autotrace on;
SELECT NAME
FROM PASSENGER
WHERE ID_PSG IN (
SELECT ID_PSG
FROM PASS_IN_TRIP PIT JOIN TRIP T on T.TRIP_NO = PIT.TRIP_NO
WHERE UPPER(TOWN_FROM) = 'MOSCOW'
)
In Script Output I can see info about the query from PLAN_TABLE table and after that there's the text:
Unable to gather statistics please ensure user has correct access. The
statistic feature requires that the user is granted select on
v_$sesstat, v_$statname and v_$session.
I've tried to find a solution here already, there's a link:
SQL Developer : Unable to gather system statistics : insufficient privileges
So I executed the same commands and the grants were all succeded:
GRANT CREATE session TO PRACTICE;
GRANT GATHER_SYSTEM_STATISTICS TO PRACTICE;
GRANT CONNECT TO PRACTICE;
Then I disconnected, closed SQL dev, opened it, connected again as it was described in the solution from the link, ran
execute dbms_stats.gather_system_stats ('START');
and got this:
PL/SQL procedure successfully completed.
Then I thought everything is fine and tried to execute the code from the very beginning and its Script Output was still the same as before.
Do I have to grant anything else or this statistics can be found in the other place or I just did everything wrong?
That error is about sqlplus autotrace, it's not about gathering system statistics like your linked post seems to be about.
There is a role created specifically for these grants called plustrace https://docs.oracle.com/database/121/SQPUG/ch_eight.htm#SQPUG535
To use this feature, you must create a PLAN_TABLE table in your schema
and then have the PLUSTRACE role granted to you. DBA privileges are
required to grant the PLUSTRACE role. For information on how to grant
a role and how to create the PLAN_TABLE table, see the Oracle Database
SQL Language Reference.
This question already has answers here:
How to find the privileges and roles granted to a user in Oracle? [duplicate]
(9 answers)
Closed 3 years ago.
I need a query which contains Oracle users with roles and privileges in one query
I Am using Oracle 11G
Of course roles can be granted to roles, granted to roles .... So if your intent is, as it seems, to see everything a given user has, regardless of directly granted or inherited through a role, through a role, through a role ... Then the definitive script is found at Pete Finnigan's site. See http://www.petefinnigan.com/find_all_privs.sql
I am new to oracle database and therefore is trying to follow the office guide. (link to the guide) However, it seems that the guide is for Windows 7, so in step 2 - creating database user, it says:
Display the SQL command prompt window. For example, on Windows, click Start, then Programs (or All Programs), then Oracle Database 11g
Express Edition, and then Run SQL Command Line.
And in windows 8, there is not start button. I try to search the menu using keyword oracle but nothing with similar name is found. I tried to go to the Program Files directly but also no similar file found. So, how should I create a database user on Windows 8?
I don't use Windows 8, but I guess that it must have some kind of a "command prompt" (you know, a program that lets you perform text-based (command-line) functions; its window is black with white letters. Once opened, the cursor blinks at the prompt, waiting for your commands). Try to find it, run it.
Then you'll be able to connect to your database (you do have it installed, right?) as
C:\> sqlplus sys/your_sys_password#database as sysdba
You'll be connected as SYS (be careful! It is a powerful user and its misuse might break your database! I'd suggest you to create another user, for example "mydba", grant it DBA role and let it perform DBA actions).
If you're unsure of what your tablespaces are, run
SQL> select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USER_DATA
APEX
APEX_9695076087226093
7 rows selected.
SQL>
as you'll need at least two of them. Now create your new user:
SQL> create user mike identified by lion
2 default tablespace user_data
3 temporary tablespace temp
4 profile default
5 quota unlimited on user_data;
User created.
SQL> grant create session to mike;
Grant succeeded.
SQL>
Granting create session, it'll be able to connect to the database, but won't be able to do anything else, so you'd have to grant it some more privileges (such as create table, create view, create procedure etc.).
SQL> connect mike/lion#orcl
Connected.
SQL> create table test (id number);
create table test (id number)
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL>
If I create a read-only user, but want to give them write access, how do I do that in CockroachDB?
At any time you can simply grant a user new permissions via the GRANT family of SQL commands, as explained in the documentation for GRANT.
For example, to grant the user jordan INSERT permissions on all tables in the test database, run the following command in a SQL shell:
GRANT INSERT ON TABLE test.* TO jordan
How can a regular developer, without admin privileges on the database, see active db connections - particularly the ones "owned" by them? Not sure if that is the right db terminology. (Application written in Java with JDBC, Oracle, and SQL Plus).
You don't need admin privileges but you would need to have permission to query the V$SESSION table (GV$SESSION if you happen to be using RAC). Your DBA can grant you the privilege to query just that table
GRANT SELECT ON sys.v_$session TO <<your user name>>
or the DBA can grant your user the SELECT ANY DICTIONARY privilege or the SELECT_CATALOG_ROLE role.
If you have one of those grants, you should be able to query V$SESSION to see all the sessions in the database.
SELECT sid, serial#, username, osuser, machine, terminal, program
FROM v$session
WHERE username = <<some user name>>
will show all the sessions in the database opened by a particular user.