SQLcl, select statement, resultant formatting of the data doesn't abide by the heading column width

188 Views Asked by At

I am using oracle SQLcl: Release 4.2.0.

When I issue this sort of select statement:

column COLUMN_A format a8
column COLUMN_B format a8
column COLUMN_C format a8
column COLUMN_D format a8
set linesize 1300
select * from table1 where rownum <= 10 order by 1;

I have the following issue:

COLUMN_A COLUMN_B COLUMN_C COLUMN_D
-------- -------- -------- --------
data1 text1 string1 date1
data2 text2 string2 date2
data3 text3 string3 date3

The data in the table output doesn't abide by the columns shown in the heading. Is there a setting that I can use so that the data in the columns fit properly in the table's columns?

I ssh into the machine that is running Oracle, via the Terminal app on a MacBook.

2

There are 2 best solutions below

0
On BEST ANSWER

Maybe upgrade?

Latest version (18.3)

drop table a8_format;
clear screen

create table a8_format (co11 varchar2(20), col2 varchar2(20), col3 varchar2(20), col4 varchar2(20));

insert into a8_format values ('data1', 'text1', 'string1', 'date1');
insert into a8_format values ('data2', 'text2', 'string2', 'date2');
insert into a8_format values ('data3', 'text3', 'string3', 'date3');
insert into a8_format values ('data4', 'text4', 'string4', 'date4');

col CO11 format a8
col col2 format a8
col col3 format a8
col col4 format a8

select * from a8_format;

Execute via F5

enter image description here

Also make sure you're using a fixed width font for the Code Editor

2
On

1.Increase the column width in format command Or 2. Use LPAD with expr2 as 12 (Or more depending upon the format spaces)