Home » RDBMS Server » Server Utilities » Query problem
Query problem [message #71135] Thu, 12 September 2002 22:08 Go to next message
sha
Messages: 84
Registered: July 2002
Member
Hi,
How can I trim the column size based on the data I entered in the column?
e.g.
name varchar2(100)
but I enter only 5 letter names
like
raj,ram etc
when I say select name from table;
it is displaying as
name
---------------------------------------------
raj
it is occupying 100 spaces and when I select another field it is displaying in the next line.
like select name,job from table;

name
-------------
job
-----------
raj
clerk
name
--------------
job
---------------
ram
accountant

in this way it is displaying
help me
thanx in advance
Re: Query problem [message #71137 is a reply to message #71135] Fri, 13 September 2002 00:03 Go to previous messageGo to next message
Phoenix
Messages: 2
Registered: January 2002
Junior Member
Hi there,

What you describe is normal SQL behaviour (select will always take column length and not the data in the column). I do not know of any way to format the output dependend on the data, but you can set the column size in sql. Try this:

col name format a20

Now execute your statement again.

If you want to select more than one column, you might want to consider a script. Something like:

col emp_id format 99 --> for numeric columns
col emp_name format a10 --> for alfanumeric columns

select emp_id
, emp_name
from employees

Hope this helps.
Re: Query problem [message #71141 is a reply to message #71135] Fri, 13 September 2002 05:42 Go to previous message
sunil bhola
Messages: 58
Registered: July 2002
Member
You can do one thing

select substr(name,1,10) from emp

it will display the column according to the length 10
Previous Topic: migration(urgent)
Next Topic: Databases with the same name in OEM
Goto Forum:
  


Current Time: Sat May 04 03:47:11 CDT 2024