Difference between revisions of "Useful aliases"
(Created page with "A small collection of my most used aliases. ==Unix== ===Quickly get into a database=== Set these in the .(bash_)profile of the oracle account alias dba='sqlplus / as sysdba' Th...") |
(→Quickly get into a database) |
||
| Line 5: | Line 5: | ||
Set these in the .(bash_)profile of the oracle account | Set these in the .(bash_)profile of the oracle account | ||
alias dba='sqlplus / as sysdba' | alias dba='sqlplus / as sysdba' | ||
| − | This will only work if a database has already been selected using ". oraenv" | + | This will only work if a database has already been selected using ". oraenv"<br /> |
When I work out how to use multi-line in an alias, this can be made better with something like: | When I work out how to use multi-line in an alias, this can be made better with something like: | ||
alias dba='export ORAENV_ASK="NO";export ORACLE_SID="$1". oraenv;sqlplus / as sysdba' | alias dba='export ORAENV_ASK="NO";export ORACLE_SID="$1". oraenv;sqlplus / as sysdba' | ||
The it could be used like so | The it could be used like so | ||
dba dev02 | dba dev02 | ||
| + | |||
===Set the SQL prompt so you can see what database you are on=== | ===Set the SQL prompt so you can see what database you are on=== | ||
In the file $ORACLE_HOME/sqlplus/admin/glogin.sql, put: | In the file $ORACLE_HOME/sqlplus/admin/glogin.sql, put: | ||
Revision as of 09:39, 5 December 2011
A small collection of my most used aliases.
Contents
Unix
Quickly get into a database
Set these in the .(bash_)profile of the oracle account
alias dba='sqlplus / as sysdba'
This will only work if a database has already been selected using ". oraenv"
When I work out how to use multi-line in an alias, this can be made better with something like:
alias dba='export ORAENV_ASK="NO";export ORACLE_SID="$1". oraenv;sqlplus / as sysdba'
The it could be used like so
dba dev02
Set the SQL prompt so you can see what database you are on
In the file $ORACLE_HOME/sqlplus/admin/glogin.sql, put:
set sqlprompt "_USER'@'_CONNECT_IDENTIFIER _PRIVILEGE> "
Might be useful to add some other often used settings:
set linesize 200 set pagesize 200
Very useful as of 10g is that this file is re-read after a connect from inside SQL*Plus
There is also a login.sql file that will be read (if it exists) which can either be in the current directory or in an environment variable $SQLPATH
Windows
Quickly get into a database
Create a file dba.bat that contains:
@echo off set ORACLE_SID=%1 sqlplus / as sysdba
Then this file will either have to be put somewhere on the %PATH%, the %PATH% modified to include the script dir or cd to the script dir before calling it.