Search This Blog

Showing posts with label environment. Show all posts
Showing posts with label environment. Show all posts

Wednesday, 29 November 2017

ORA-02030 error when try to grant permissions to a v$ tables

Face with an error ORA-02030 when you try to give permission on a v$ view

SQL> grant select on v$session to hr;
grant select on v$session to hr
*
ERROR at line 1:
ORA-02030: can only select from fixed tables/views

Why it couldn’t give select privileges to a v$ view. If you tried to give permission to other v$views you will face same the error.

The problem is caused because of trying to give select privileges on a synonym. Oracle v$ views are named V_$VIEWNAME and they have synonyms in format V$VIEWNAME and you can’t give privilage on a synonym.
If you want to give permission to a V$ view you must grant permissions like below:

SQL> grant select on v_$session to hr;
Grant succeeded.

Wednesday, 30 August 2017

Oracle File extensions

SQL*Plus files
.sql - SQL script
.lst - spool file

PL/SQL files
.pls - PL/SQL source
.plb - PL/SQL binary
.pks - Package source or package specification
.pkb - Package binary or package body
.pck - Combined package specification plus body

Oracle database files
.dbf - database file
.log - Online Redo Log
.rdo - Online Redo Log
.arc - Archive log

SQL*Loader files
.ctl - Control file
.dat - Data file
.bad - Bad file
.dsc - Discard file

SQL*Net files
.ora - tnsnames.ora, sqlnet.ora, etc.

Forms files
.fmb - Forms binary
.fmt - Forms text
.fmx - Forms executable

Reports files
.rdf - contains a single report definition in binary format. 
        .rdf files are used to both run and edit reports.
.rep - contains a single report definition in binary format. 
          .rep files are used solely to run reports; you cannot edit a .rep file
.rex - contains a single report definition in text format. .REX files are portable.

Tuesday, 29 August 2017

Switching to a Different Schema

The following statement sets the schema of the current session to the schema name specified in the statement.
ALTER SESSION SET CURRENT_SCHEMA = <schema name>;
In subsequent SQL statements, Oracle Database uses this schema name as the schema qualifier when the qualifier is omitted. In addition, the database uses the temporary tablespace of the specified schema for sorts, joins, and storage of temporary database objects. The session retains its original privileges and does not acquire any extra privileges by the preceding ALTER SESSION statement.
You can use this command above to avoid the use of public synonyms.  By setting the CURRENT_SCHEMA attribute to the schema owner name it is not necessary to create public synonyms for production table names. Without the current_schema syntax, you would have to assign a public synonym for every table in your production database.
If you want to check the current schema of the session you can use the following statement:
SELECT sys_context( 'userenv', 'current_schema' ) from dual; 

Let's look in the following example:

CONNECT user1
ALTER SESSION SET CURRENT_SCHEMA = schema_2;
SELECT * FROM empoyers;

Because user1 is not schema-qualified, the table name is resolved under schema schema_2. But if user1 does not have select privilege on table schema_2.empoyers, then user1 cannot execute the SELECT statement even switching the current session schema.

Search This Blog