Gather database statics

There are several ways to gather statics in Oracle. It all depends on how wide you want to do your collection.

To gather statics for the whole database:

SQL> EXEC DBMS_STATS.gather_database_stats;

To gather statics for a single schema:
SQL> EXEC DBMS_STATS.gather_schema_stats('SCOTT');

To gather statics for a single table:SQ

L> EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMPLOYEES');

To gather statics for a single index:
SQL> EXEC DBMS_STATS.gather_index_stats('SCOTT', 'EMPLOYEES_PK');

For more information see:
http://www.oracle-base.com/articles/8i/CostBasedOptimizerAndDatabaseStatistics.php

Compiling schema objects

The COMPILE_SCHEMA procedure in the DBMS_UTILITY package compiles all procedures, functions, packages, and triggers in the specified schema.

The example below shows how it is called from SQL*Plus for the SCOTT schema.

SQL> EXEC DBMS_UTILITY.compile_schema(schema => 'SCOTT');

Shell script parameter check

To check if your script was given any command like parameters when run use scripts similar to the following,

in BASH use:
if [ $# -ne 2 ]
then
echo “Error in $0 – Invalid Argument Count”
echo “Syntax: $0 input_file output_file”
exit
fi

is CSH use:
if( $#argv < 2 ) then
echo “Usage: pltrps filename start_rpnum [ rpnum_inc END_rpnum]”
exit 1
endif

Connecting to MySQL

At your shell prompt type

# mysql -u <username>  --password=<password>

Where <username> and <password> are the username and password you entered when first setting up MySQL.
You may also be able to login as root like this,

# mysql -u root

without using a password, depending on how your system was setup.