Compute statistics in Oracle

sqlplus user/password@db

SQL> set echo off
SQL> set feed off
SQL> set head off
SQL> spool analyze_tables.sql
SQL> select ‘analyze table ‘||table_name||’ compute statistics;’ from user_tables;
SQL> spool off
SQL> exit

sqlplus user/password@db @analyze_tables.sql

Callback : group right

In RT you can allow only people from a certain group to see a Callback, e.g:


my $group = new RT::Group($session{'CurrentUser'});
$group->LoadUserDefinedGroup('My_Group');
if ($group->HasMemberRecursively($session{'CurrentUser'}->PrincipalObj)) {
$toptabs->{'My_Callback'} = { title =>loc("My_Callback"),
path => "My_Callback/index.html" };

}

How do I reset ‘sa’ password in SYBASE

When SYBASE get started, the following call is made:

startserver -f RUN_MYINSTANCE

RUN_MYINSTANCE is located in $SYBASE_HOME/install.

1/ edit RUN_MYINSTANCE and add the following line, where the switches are:

-psa

2/ run startserver -f RUN_MYINSTANCE

During the boot phase you will see something like, e.g:
New SSO password for sa:uvwxyz

You can also see this message in Sybase logs.

3/ edit RUN_MYINSTANCE and remove the line you added in step 1/, so you do not reset it next time.

4/Set your own password:

isql -Usa -SMYINSTANCE (using ‘uvwxyz’ password)

>sp_password “uvwxyz”,”my_own_password”
>go

Check process using strace

strace -f -r -o pid.out -p {PID}

Load .csv file in MySQL

LOAD DATA LOCAL INFILE 'file.csv'
INTO TABLE my_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field_a, field_b, field_c, field_d);

Increasing the number of ‘user connections’ in SYBASE

Default value : 25

$isql -Usa -SMYINSTANCE

>sp_configure ‘user connections’, 100

No reboot is required since this option is dynamic.
Changing the value of ‘number of user connections’ to ’100′ increases the amount of memory ASE uses by 17740 K.

Stored Procedures in Sybase

sp_configure – set db parameters

sp_dboption – set db options

sp_displaylogin – Show login details

sp_help object_name – Object definitions

sp_helpdb dbname – db info

sp_helpdevice - device info

sp_helpindex - index per table info

sp_helpprotect userid – Privileges info

sp_helpsegment – Monitor db sizing

sp_helptext stord_proc – Show stored procs code

sp_helpuser userid - User info

sp_spaceused – db sizing

sp_who userid – Users logged in info

Monitoring system using sar

The sar command writes to standard output the contents of selected cumulative activity counters in the operating system, e.g:

nohup sar -A -o /tmp/activity 60 0 1>/dev/null 2>&1 &

Backup directories with perl/tar

#!/usr/bin/perl -w

use strict;
use POSIX qw(strftime);

my $target_directory=shift(@ARGV);
chomp($target_directory);
$target_directory =~ tr/\///d;
print "Zipping $target_directory/* ...\n";
my $set_time = strftime "%d-%m-%Y_%H%M", localtime;
my $zipped_directory=$target_directory."_".$set_time.".tar.gz";
my $command = "tar -zpcvf ".$zipped_directory." ".$target_directory."/*";
system($command);
print("\n");