Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLPLUS output: How to automatically get minimal column width for each column?

Tags:

oracle

sqlplus

I tried set linewidth, but that wasn't my intention, is there anyway to shrink each columns width to the minimum that will fit the values? or auto substring each column so that they all fit in the screen?

thanks.

like image 924
fenerlitk Avatar asked Apr 30 '12 10:04

fenerlitk


People also ask

How do I set COL size in Sqlplus?

You can change the displayed width of a datatype or DATE, by using the COLUMN command with a format model consisting of the letter A (for alphanumeric) followed by a number representing the width of the column in characters. If you specify a width shorter than the column heading, SQL*Plus truncates the heading.

How do I find the size of a column in SQL Developer?

Answer: There are many ways to determine the length of a specify column, and it depends on the datatype. Current to the last run of dbms_stats, you can use the DBA_TAB_COLUMNS view, using the AVG_COL_LEN or CHAR_COL_DECL_LENGTH columns.

What is set Pagesize in Oracle?

The PAGESIZE setting tells SQL*Plus the number of printed lines that will fit on one page of output.

What is set echo on in Oracle?

The ECHO setting tells SQL*Plus whether you want the contents of script files to be echoed to the screen as they are executed.


1 Answers

You can use

COLUMN columnname FORMAT An

for Char, VARCHAR2 (VARCHAR), LONG columns

where n is the the desired display width and columnname is a column of a table

for example

COLUMN title FORMAT a40

For different datatype like Number and other options you can refer the below link

http://ss64.com/ora/syntax-sqlplus-fmt.html

The big limitation is that you can't set an fixed width for all VARCHAR2 columns, only for specific ones.

like image 87
psaraj12 Avatar answered Nov 13 '22 22:11

psaraj12