Nov 16, 2010

Zone Commands

prstat - top like command that can be run on zones and give some nice memory / cpu summary information of what is going on with the zones.

/usr/sbin/arp -a - nice way of finding what the global zone is.

Sep 22, 2010

sql escape character setup

in sqlplus setting the "&" as a literal, you need to do the following.
set escape \
select * from bla where blabla = 'xxx \&';
note: you should really set the escape sqlplus parameter in a glogin.sql or login.sql

Sep 21, 2010

sample login.sql using sql variabes

Use the following to set up variables that are based on values from sql output.
Use the new_value option in the sqlplus column command.
See the example below which grabs the instance name of the database that is being used.

SQL> set termout off timing off feedback off
SQL> column instance new_value instance_name
SQL> select instance_name instance from v$instance ;
SQL> set termout on timing on feedback on
SQL> prompt &instance_name


note: The first set statement hides the output from running the v$instance sql query.

Jun 24, 2010

excel - auto calculations

If excel is not auto calculating then check -

TOOLS/OPTIONS/CALCULATION and make sure that the automatic option is selected under "Calculation".

Jun 4, 2010

unix user management commands

Various commands to create groups, add groups to users and make a group the default group.

Create New Group
# groupadd -g "groupid" "groupname"

Add Group to user, additional group
# usermod -G "groupname" "username"

Add Group to user, primary group
# usermod -g "groupname" "username"

Apr 16, 2010

unix - redirecting output

In UNIX, run the following to ensure any errors (known as stderr) is not displayed on the screen.

Use 2> /dev/null

i.e.:

df -k 2> /dev/null

This works when using the ksh shell. There will be other derivitives when using other shells.

Feb 3, 2010

transportable tablespaces

References: metalink note:77523.1

Refer to the relevant database documentation, correct version for restrictions when using this feature.

note:

a Ensure the following scripts have been run in the database. These would normally be run at database creation time.

$ORACLE_HOME/rdbms/admin/catplug.sql
$ORACLE_HOME/rdbms/admin/dbmsplts.sql
$ORACLE_HOME/rdbms/admin/prvtplts.plb

sql> desc dbms_plugts

b If running this procedure by a user other than sys then ensure the user has dba privileges and PUBLIC SYNONYMS for the following following have been created.

DBMS_PLUGTS
DBMS_TTS


1. Identify tablespaces that need to be migrated. note: Dependent data objects need to be incapsuated in the process. i.e.: Data + Index objects need to be included.

2. Put relevent tablespaces into readonly mode.

sql> alter tablespace ... readonly;

3. Export metadata from tablesspaces
unix> exp userid/password file=... tablespaces=... transport_tablespaces=y

note: multiple tablespaces need to be delimited by a comma.

4. Copy datafiles that make up the tablespaces identified above into the target environment.

5. Copy the export dat file created in step 3.

6. Import metadata into target database.

unix> imp ... tablespaces=... datafiles=... transport_tablespaces=y
note: tablespaces and datafiles need to be seperated by comma's.

7. Verify tablespaces are updated correctly by querying relevent views, dba_tablespaces and v$datafile.

8. Put tablespaces into read write mode in source and target databases.
sql> alter tablespace ... read write;