gqlplus – sqlplus with readline (tab completion)

2012-08-03 1 min read Database

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

2012-02-27 1 min read Database

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

Oracle GUI client on Linux with mysql support

2010-06-22 1 min read Fedora Linux

I was looking for some nice client for Oracle and mysql. I did find mysql-administrator and navicat to be useful but this is much better. <a href="http://sourceforge.net/projects/tora/" target="_blank">Tora is the client that I am talking about. Installation did not take much time for me..

downloaded the instant client from oracle.com and then the tora rpm from sourceforge.net. Also downloaded the tora-mysql from http://rpm.pbone.net/index.php3/stat/21/year/2002/month/01/day/28

Then tried to install all the rpms found the rpms that were missing and installed them using yum. Once this is done install the downloaded rpms with &#8221;–nodeps&#8221; option of rpm.Put the entries in bashrc

Continue reading

SQuirrel SQL for Graphical interface to Oracle/MySQL and loads of other database -- OSS and free.

2010-06-04 1 min read Linux

<a href="http://blog.amit-agarwal.co.in/category/linux/">Bookmark this category

SQuirrel <a class="zem_slink freebase/en/sql" title="SQL" rel="wikipedia" href="http://en.wikipedia.org/wiki/SQL">SQL for <a class="zem_slink freebase/en/graphical_user_interface" title="Graphical user interface" rel="wikipedia" href="http://en.wikipedia.org/wiki/Graphical_user_interface">Graphical interface to Oracle/MySQL and loads of other <a class="zem_slink freebase/en/database" title="Database" rel="wikipedia" href="http://en.wikipedia.org/wiki/Database">database — <a class="zem_slink freebase/en/open_sound_system" title="Open Sound System" rel="homepage" href="http://www.opensound.com/">OSS and free.

<a class="zem_slink freebase/en/squirrel_sql_client" title="SQuirreL SQL Client" rel="homepage" href="http://www.squirrelsql.org/">SQuirreL SQL Client is a graphical SQL client written in <a class="zem_slink freebase/guid/9202a8c04000641f800000000f8545aa" title="Java (programming language)" rel="homepage" href="http://java.sun.com">Java that will allow you to view the structure of a <a class="zem_slink freebase/en/java_database_connectivity" title="Java Database Connectivity" rel="wikipedia" href="http://en.wikipedia.org/wiki/Java_Database_Connectivity">JDBC compliant database, browse the <a class="zem_slink freebase/en/data" title="Data" rel="wikipedia" href="http://en.wikipedia.org/wiki/Data">data in tables, issue SQL commands etc. The pre-requisites are java 1.5 and 1.6 in the sequence of the <a class="zem_slink freebase/en/installation" title="Installation (computer programs)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Installation_%28computer_programs%29">installer versions! Installers available at: <a href="http://sourceforge.net/projects/squirrel-sql/files/">http://sourceforge.net/projects/squirrel-sql/files/ Home page and installation instructions at: <a href="http://www.squirrelsql.org/#installation">http://www.squirrelsql.org/#installation Have a nice time with the SQuirreL!!<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/04/27/fvwm-look-and-feel-icons-and-themes/">fvwm Look and Feel, icons and themes (amit-agarwal.co.in) <li class="zemanta-article-ul-li"><a href="http://checkedexception.blogspot.com/2010/03/using-ms-sql-from-linux.html">Using MS SQL from Linux (checkedexception.blogspot.com) <li class="zemanta-article-ul-li"><a href="http://briancarper.net/blog/adminer-where-have-you-been-all-my-life">Adminer, where have you been all my life? (briancarper.net) <li class="zemanta-article-ul-li"><a href="http://helpdeskgeek.com/databases/an-introduction-to-oracle-sql-developer-part-v/">An Introduction to Oracle SQL Developer – Part V (helpdeskgeek.com) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/6c1be63c-1479-4ac2-9707-3e8c8b750585/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b12.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">

Continue reading

bash script with sql to get the number of records from multiple tables.

2010-02-10 1 min read Bash Database Learning Linux Solaris

Here is the bash script:

#!/bin/sh
names[1]=errorlog
names[2]=amit1log
names[3]=amit2log
names[4]=amit3log
names[5]=amit4log
j=1
echo $1
for i in $( sqlplus amit/passwd@tns @get_count.sql |sed  -n &#8217;/COUNT/,/Disconnected/p&#8217;|sed &#8217;/COUNT/ d&#8217;|sed &#8217;/—/ d&#8217;|sed &#8217;/Disconnected/ d&#8217;|tr &#8217;n&#8217; &#8217; &#8217;  )
do
temp=${names[$j]}
let count=30-${#temp}
for ((I=1; I <= $count ; I++))
do
printf &#8221; &#8221;
done
echo  &#8221;${names[$j]}    : $i&#8221;
# echo $j
let j=j+1
done
echo
echo

and the required sql script:

select count() from errorlog;
select count(
) from amit1log;
select count() from amit2log;
select count(
) from amit3log;
select count(*) from amit4log;
quit;

Continue reading