This discussion is archived
2 Replies Latest reply: Jan 13, 2012 3:16 PM by 643298 RSS

Query output result on shell is a big mess

911013 Newbie
Currently Being Moderated
Hello,
I just installed Oracle Express on Ubuntu 11.10. Then I tried using SQL*PLUS by running the query "select * from hr.employees;". But the output was a mess. Can anyone help me with formatting the output?
Besides, I want this to be a permanent change not just for the current session.

This is how it looks after I ran the query "select * from hr.employees;"
http://img21.imageshack.us/img21/4639/screenshotat20120113210.png

Edited by: 908010 on Jan 13, 2012 11:17 AM
  • 1. Re: Query output result on shell is a big mess
    Brian Bontrager Expert
    Currently Being Moderated
    Formatting SQL*Plus Reports
    http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_six.htm#i1081008

    SQL*Plus Configuration (or using a login.sql file so every time you start sqlplus your preferences are loaded)
    http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_two.htm#i1132910
  • 2. Re: Query output result on shell is a big mess
    643298 Newbie
    Currently Being Moderated
    Set off with a wider console using SET LINESIZE 180. Then add few useful settings like SET PAGES 50000 for having headers printed only once every 50k rows, SET TAB OFF to prevent replacing of multiple spaces with tab characters plus SET TRIMOUT ON and SET TRIMSPOOL ON to get rid of trailing spaces at line ends.

    To format individual columns use column clause:
    column first_name format a20
    column last_name format a20
    column email format a30
    Finally, to make these persistent, place them in either site global configuration script under $ORACLE_HOME/sqlplus/admin/glogin.sql or local one at ~/login.sql.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points