ankitaP
ankitaP

Reputation: 85

Display full column name instead of shortened

If I write:

Select DUMMY from DUAL;

it's displayed as follows:

D
-
X

Why is the column name 'D' here ? Why not the full "DUMMY"? How can I get the result to display as follows?

Dummy
-----
  X

The above problem is now solved. Now, what would be done if we want back to its default ?

    col dummy format a1;
    insert into tab values('a');
    insert into tab values('ank');
    select * from tab;

The Output is :

    D
    -
    a
    a
    n
    k                                                                   

This 'Dummy' column is NOT from Dual table. Its my own created table 'tab'.

Upvotes: 2

Views: 6744

Answers (2)

DazzaL
DazzaL

Reputation: 21973

SQL*Plus will format the column width to the size of the datatype. in the case of DUAL, DUMMY is a varchar2(1). you can control this with

col DUMMY format a5

ie:

SQL> select * from dual;

D
-
X

SQL> col DUMMY format a5
SQL> select * from dual;

DUMMY
-----
X

Upvotes: 9

Art
Art

Reputation: 5782

"Cheating"

Select rpad('x', 5, ' ') DUMMY from DUAL
/

SQL>

DUMMY
-----
x

Upvotes: 1

Related Questions