Promena konektovane šeme

Change Current_Schema

 

Promena konektovane šeme. 1

Primer 1. 1

Set Current_Schema to SCOTT. 1

Pristup podacima kao CURRENT_SCHEMA.. 2

Sys_context function - Oracle environment info. 2

Primeri: 4

 

Primer 1

 

SQL> connect

Enter user-name: / as sysdba

Connected.

SQL> / as sysdba

 

SYS_CONTEXT('USERENV','CURRENT_SCHEMA')

-----------------------------------------------------------------

SYS

 

SQL> SELECT sys_context('USERENV', 'SESSION_USER') FROM dual;

 

SYS_CONTEXT('USERENV','SESSION_USER')

-----------------------------------------------------------------

SYS

 

SQL> SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual;

 

SYS_CONTEXT('USERENV','CURRENT_SCHEMA')

-----------------------------------------------------------------

SYS

 

Set Current_Schema to SCOTT

 

SQL> ALTER SESSION SET CURRENT_SCHEMA =scott;

 

SQL> SELECT sys_context('USERENV', 'SESSION_USER') FROM dual;

 

SYS_CONTEXT('USERENV','SESSION_USER')

-----------------------------------------------------------------

SYS

 

SQL> SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual;

 

SYS_CONTEXT('USERENV','CURRENT_SCHEMA')

-----------------------------------------------------------------

SCOTT

 

Pristup podacima kao CURRENT_SCHEMA

 

SQL> desc moja_tabela

 Name                                                                          Null?    Type

 ----------------------------------------------------------------------------- -------- -------------

 COL1                                                                                   VARCHAR2(14)

 COL2                                                                                   VARCHAR2(14)

 

Sys_context function - Oracle environment info

Syntax sys_context( namespace, parameter, [ length ] )

The valid parameters for the namespace called 'USERENV' are as follows:

Parameter

Explanation

Return Length

AUDITED_CURSORID

Returns the cursor ID of the SQL that triggered the audit

N/A

AUTHENTICATION_DATA

Authentication data

256

AUTHENTICATION_TYPE

Describes how the user was authenticated. Can be one of the following values: Database, OS, Network, or Proxy

30

BG_JOB_ID

If the session was established by an Oracle background process, this parameter will return the Job ID. Otherwise, it will return NULL.

30

CLIENT_IDENTIFIER

Returns the client identifier (global context)

64

CLIENT_INFO

User session information

64

CURRENT_SCHEMA

Returns the default schema used in the current schema

30

CURRENT_SCHEMAID

Returns the identifier of the default schema used in the current schema

30

CURRENT_SQL

Returns the SQL that triggered the audit event

64

CURRENT_USER

Name of the current user

30

CURRENT_USERID

Userid of the current user

30

DB_DOMAIN

Domain of the database from the DB_DOMAIN initialization parameter

256

DB_NAME

Name of the database from the DB_NAME initialization parameter

30

ENTRYID

Available auditing entry identifier

30

EXTERNAL_NAME

External of the database user

256

FG_JOB_ID

If the session was established by a client foreground process, this parameter will return the Job ID. Otherwise, it will return NULL.

30

GLOBAL_CONTEXT_MEMORY

The number used in the System Global Area by the globally accessed context

N/A

HOST

Name of the host machine from which the client has connected

54

INSTANCE

The identifier number of the current instance

30

IP_ADDRESS

IP address of the machine from which the client has connected

30

ISDBA

Returns TRUE if the user has DBA privileges. Otherwise, it will return FALSE.

30

LANG

The ISO abbreviate for the language

62

LANGUAGE

The language, territory, and character of the session. In the following format:
     language_territory.characterset

52

NETWORK_PROTOCOL

Network protocol used

256

NLS_CALENDAR

The calendar of the current session

62

NLS_CURRENCY

The currency of the current session

62

NLS_DATE_FORMAT

The date format for the current session

62

NLS_DATE_LANGUAGE

The language used for dates

62

NLS_SORT

BINARY or the linguistic sort basis

62

NLS_TERRITORY

The territory of the current session

62

OS_USER

The OS username for the user logged in

30

PROXY_USER

The name of the user who opened the current session on behalf of SESSION_USER

30

PROXY_USERID

The identifier of the user who opened the current session on behalf of SESSION_USER

30

SESSION_USER

The database user name of the user logged in

30

SESSION_USERID

The database identifier of the user logged in

30

SESSIONID

The identifier of the auditing session

30

TERMINAL

The OS identifier of the current session

10

 

 

sys_context Primeri

 

SELECT sys_context('USERENV', 'OS_USER') FROM dual;

SELECT sys_context('USERENV', 'TERMINAL') FROM dual;