Showing posts with label set numwidth. Show all posts
Showing posts with label set numwidth. Show all posts

Monday, March 03, 2014

Justify Left, Centre and Right

This was tested on Oracle 11.2. NUMBER items and their column headings are right justified by default:
 
SQL> set numwidth 15
SQL> select count(*) table_count from dba_tables
  2  /
 
    TABLE_COUNT
---------------
           3110
 
SQL>
 
If you want to see the heading in the centre of the column, you can do so with justify centre:
 
SQL> col table_count justify centre
SQL> select count(*) table_count from dba_tables
  2  /
 
  TABLE_COUNT
---------------
           3110
 
SQL>
 
If you want to see the heading to the left of the column, you can do so with justify left:
 
SQL> col table_count justify left
SQL> select count(*) table_count from dba_tables
  2  /
 
TABLE_COUNT
---------------
           3110
 
SQL>
 
VARCHAR2 items and their column headings are left justified by default:
 
SQL> select table_name from dba_tables
  2  where rownum = 1
  3  /
 
TABLE_NAME
------------------------------
CON$
 
SQL>
 
If you want to see the heading in the centre of the column, you can do so with justify centre:
 
SQL> col table_name justify centre
SQL> select table_name from dba_tables
  2  where rownum = 1
  3  /
 
          TABLE_NAME
------------------------------
CON$
 
SQL>
 
If you want to see the heading to the right of the column, you can do so with justify right:
 
SQL> col table_name justify right
SQL> select table_name from dba_tables
  2  where rownum = 1
  3  /
 
                    TABLE_NAME
------------------------------
CON$

Tuesday, January 25, 2011

NUMWIDTH


You can use NUMWIDTH to prevent large numbers being displayed in scientific notation. First check the current value of NUMWIDTH:

SQL> show numwidth
numwidth 10
SQL>

Next, display a large number. As it is more than NUMWIDTH digits long, it appears in scientific notation:

SQL> select sum(bytes) from dba_data_files;

SUM(BYTES)
----------
1.2863E+11

SQL>

This will need a NUMWIDTH of 12 or more to be displayed as a normal number:

SQL> set numwidth 12
SQL> l
  1* select sum(bytes) from dba_data_files
SQL> /

  SUM(BYTES)
------------
128625672192

SQL>