Friday, September 8, 2017

SQL*Plus: Format column width to display a column at a specified length

Lets say that you have a FRUIT table with the following schema.

Name                      Type
-----------------         ---------------------------
NAME                      VARCHAR2(100)
PRICE                       NUMBER
DESC                        VARCHAR2(100)

Since most of the names of your fruits are far more less than 100 characters, there is a big empty space after each name in your query result, and you want to reduce that.

SQL> COLUMN Name FORMAT A50
SQL> select * from FRUITS;

This will reduce the Name column in your query result to 50 characters. Any name longer than 50 characters is truncated.

Reference:
1. Formatting SQL*Plus Reports

---------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment