Tag: Database

Shortcut to run current command with sudo in bash

For me, I mostly forget to add “sudo” to the command until the time I am actually supposed to run it. Also sometimes, on some systems, bash completion does not work as expected with “sudo”. With these in mind, I wanted something such that when I have completed the command, I could insert sudo in the begining of the command without much ado. So, finally this is what I came up with in my “~/.inputrc” file. Note: If you don’t have this file, then simply create this file.

"C-k":"C-a sudo n"
Enhanced by Zemanta

gqlplus – sqlplus with readline (tab completion)

Tab completion is something which is missing in the sqlplus and if you have lot of tables with long names or lot of columns then it is sufficiently┬á difficult to type them ­čÖé

Here is a solution for this problem. Download and install gqlplus. gqlplus is a replcement for sqlplus which supports completion for commands/tablenames and column names. Quite useful.

Oracle SQL*Plus
Oracle SQL*Plus (Photo credit: Manuel Cernuda)
Enhanced by Zemanta

Oracle Select the top 5 queries

Here are one sql script that I found some time back. This will be listing the top 5 SQL queries in Oracle.

SET linesize 300
SET PAGESIZE 200
select *
from
(select sql_text,
        sql_id,
        elapsed_time,
        cpu_time,
        user_io_wait_time
from    sys.v_$sqlarea
order by 5 desc)
where rownum < 6;
quit;
Enhanced by Zemanta