Tuesday, August 19, 2014

How to check UNDO tablespace total and occupied size

select tablespace_name,sum(bytes) total_bytes from dba_data_files where tablespace_name like '%UNDO%' group by tablespace_name;

select tablespace_name,sum(bytes) occupied_bytes from dba_segments where tablespace_name like '%UNDO%' group by tablespace_name;

Thursday, August 14, 2014

How to ssh to host and set terminal title to hostname:path_on_the_host in a single command

 1. Create file ~/ssht.sh with content:

#!/bin/bash
SETTP='MY_PROMPT="$HOSTNAME:$PWD\$ "'
SETTP="$SETTP;"'MY_TITLE="\[\e]0;$HOSTNAME:$PWD\a\]"'
SETTP="$SETTP;"'PS1="$MY_TITLE$MY_PROMPT"'
ssh -t <YOUR_NICKNAME>@$1 "export PROMPT_COMMAND='eval '\\''$SETTP'\\'; bash --login"

2. Make it executable:

chmod ugo+x ~/ssht.sh

3. add alias to this script into your .profile:

alias ssht="~/ssht.sh"

4. Use:

ssht <HOST_NAME>