I ran the simple select query in the command prompt,but the output rows are not coming in a single line. See below:
SQL> set pagesize 2000
SQL> select * from xtern_empl_rpt ;
EMP LAST_NAME
--- --------------------------------------------------
FIRST_NAME SSN
-------------------------------------------------- ---------
EMAIL_ADDR
--------------------------------------------------------------------------------
YEARS_OF_SERVICE
----------------
001 Hutt
Jabba 896743856
jabba@thecompany.com
18
002 Simpson
Homer 382947382
homer@thecompany.com
20
003 Kent
Clark 082736194
superman@thecompany.com
5
004 Kid
Billy 928743627
billythkid@thecompany.com
9
005 Stranger
Perfect 389209831
nobody@thecompany.com
23
006 Zoidberg
Dr 094510283
crustacean@thecompany.com
1
6 rows selected.
SQL>
Could you please help me to make each rows in a single line?
Edit
I tried below,but still is not prettified.
SQL> SET LINESIZE 4000
SQL> select * from xtern_empl_rpt ;
EMP LAST_NAME FIRST_NAME
SSN EMAIL_ADDR
YEARS_OF_SERVICE
--- -------------------------------------------------- -------------------------
------------------------- --------- --------------------------------------------
-------------------------------------------------------- ----------------
001 Hutt Jabba
896743856 jabba@thecompany.com
18
002 Simpson Homer
382947382 homer@thecompany.com
20
003 Kent Clark
082736194 superman@thecompany.com
5
004 Kid Billy
928743627 billythkid@thecompany.com
9
005 Stranger Perfect
389209831 nobody@thecompany.com
23
006 Zoidberg Dr
094510283 crustacean@thecompany.com
1
6 rows selected.
SQL>
set your column widths to fit in the screen
eg:
where a is hte column width. you can use WRA to wrap the column
eg
or
TRUto truncate,WORto break on word boundariesfor example:
so the output is a bit tricky to read as email_addr was padded to 300 characters (as my table had it defined as varchar2(300) which sql*plus uses to format the output).
first set an appropriate linesize:
now lets set the columns so they fit on one line (linesize should be greater than the total col widths):
so now the columns fit easily onto a reasonably sized terminal.
in your case
first_nameandlast_nameare varchar2(50)’s yet the data in them is much smaller, so i’d start withcolumn first_name format a15(same for last_name). with email, your column is varchar2(100) yet the max sized output was 25 chars, so putcolumn email format a25for a starter.if you did that, you should get output (if linesize is high enough) like:
finally as requested.
WRATRUandWOR.WRAis default by the way, so you dont have to use it but lets say we had:but i wanted to format this as 10 characters width:
S
the
WRAmeans just chop the string at 10 chars, regardless of whether we are in the middle of a word or not. if we wanted to break ONLY on word endings (where possible as a word > 10 still needs to break):now the output is broken at word boundaries and not necessarily at 10 chars.
if we only wanted the first 10 chars and no line wrapping, we could use
TRU: