COLUMN report_date_col NEW_VALUE report_date
col report_date_col noprint
SELECT TO_CHAR ( SYSDATE ,'DD-Mon-YYYY:HH:MI') AS report_date_col FROM dual;
TTitle left "*** Rollback Information ( Date: &report_date ) ***" skip 2
Showing posts with label sqlplus. Show all posts
Showing posts with label sqlplus. Show all posts
Saturday, July 28, 2012
Tuesday, June 12, 2012
How to get my Oracle session informations
In Oracle/PLSQL, the userenv function can be used to
retrieve information about the current Oracle session.
The syntax for the userenv function is:
userenv( parameter )
parameter is the value to return from the current Oracle session.
The possible values for parameter are:
The syntax for the userenv function is:
userenv( parameter )
parameter is the value to return from the current Oracle session.
For Example:
| userenv('ENTRYID') | would return FALSE |
| userenv('LANGUAGE') | would return 'AMERICAN_AMERICA.WE8DEC' |
The possible values for parameter are:
| Parameter | Explanation |
|---|---|
| CLIENT_INFO | Returns user session information stored using the DBMS_APPLICATION_INFO package |
| ENTRYID | Available auditing entry identifier |
| INSTANCE | The identifier number of the current instance |
| ISDBA | Returns TRUE if the user has DBA privileges. Otherwise, it will return FALSE. |
| LANG | The ISO abbreviation for the language |
| LANGUAGE | The language, territory, and character of the session. In the following format: language_territory.characterset |
| SESSIONID | The identifier of the auditing session |
| TERMINAL | The OS identifier of the current session |
Monday, June 11, 2012
script to identify all objects belonging to a tablespace in Oracle
select owner
, segment_name
, segment_type
from dba_segments
where lower(tablespace_name) like lower('%&tablespace%')
order by owner, segment_name
Saturday, May 19, 2012
Setting up Autotrace in SQL*Plus
AUTOTRACE is a facility within SQL*Plus to show us the explain plan of the queries we've executed, and
the resources they used. There is more than one way to get AUTOTRACE configured.
This is how i do to get AUTOTRACE working:
• cd $ORACLE_HOME/rdbms/admin (or cd %ORACLE_HOME%/rdbms/admin on Windows)
• log into SQL*Plus as SYSTEM ==> sqlplus system/pass@alias
• run @utlxplan
• run CREATE PUBLIC SYNONYM PLAN_TABLE FOR PLAN_TABLE;
• run GRANT ALL ON PLAN_TABLE TO PUBLIC;
You can replace the GRANT TO PUBLIC with some user if you want. By making it public, you let
anyone trace using SQL*Plus. This prevents every user from having to install their own plan table. The alternative is for you to run @utlxplan in every schema from which you
want to use AUTOTRACE.
The next step is creating and granting the PLUSTRACE role:
• cd $ORACLE_HOME/sqlplus/admin (or cd %ORACLE_HOME%/sqlplus/admin on Windows)
• log into SQL*Plus as SYS or AS SYSDBA
• run @plustrce
• run GRANT PLUSTRACE TO PUBLIC;
Again, you can replace PUBLIC in the GRANT command with some user if you want.
the resources they used. There is more than one way to get AUTOTRACE configured.
This is how i do to get AUTOTRACE working:
• cd $ORACLE_HOME/rdbms/admin (or cd %ORACLE_HOME%/rdbms/admin on Windows)
• log into SQL*Plus as SYSTEM ==> sqlplus system/pass@alias
• run @utlxplan
• run CREATE PUBLIC SYNONYM PLAN_TABLE FOR PLAN_TABLE;
• run GRANT ALL ON PLAN_TABLE TO PUBLIC;
You can replace the GRANT TO PUBLIC with some user if you want. By making it public, you let
anyone trace using SQL*Plus. This prevents every user from having to install their own plan table. The alternative is for you to run @utlxplan in every schema from which you
want to use AUTOTRACE.
The next step is creating and granting the PLUSTRACE role:
• cd $ORACLE_HOME/sqlplus/admin (or cd %ORACLE_HOME%/sqlplus/admin on Windows)
• log into SQL*Plus as SYS or AS SYSDBA
• run @plustrce
• run GRANT PLUSTRACE TO PUBLIC;
Again, you can replace PUBLIC in the GRANT command with some user if you want.
Wednesday, May 16, 2012
This is how i customize my sqlplus prompt
I often use sqlplus to perform my daily
administrative tasks and i work on multiple servers that contain
multiple databases, each database contains multiple accounts.
When connected to a database, i need to know my username and my database connection to reassure me that I point to the correct database in order to avoid errors that could be catastrophic.
To customize your sqlplus prompt
- Navigate to the directory $ORACLE_HOME/sqlplus/admin
- Create a file login.sql (or edit the file if it already exists) using vi on unix / Linux or notepad on windows
- SET SQLPROMPT '&_USER.@&_CONNECT_IDENTIFIER.> '
The next time you will login your sqlplus prompt will look like this : user@alias
Here is a complete list of SQL*Plus variables that you can use to customize your prompt.
There are eight variables defined during SQL*Plus installation. These
variables only differ from user defined variables by having predefined
values.Tuesday, May 15, 2012
Establish a direct connection to Oracle from sqlplus (without an alias)
People like us who change environments all the time with various customers, not to waste time configuring a connection alias in the tnsnames.ora file you can directly connect to an ORACLE database from sqlplus using
sqlplus user/pass@server_ip:port/sid
ex: sqlplus guy/fomi@10.10.10.10:1521/test
sqlplus user/pass@server_ip:port/sid
ex: sqlplus guy/fomi@10.10.10.10:1521/test
Monday, May 14, 2012
SQLPLUS SET System Variable Summary
I need to lookup these variables very often for my sqlplus scripts
Subscribe to:
Posts (Atom)