-
Specify column width from within a query
Hi,
I was wondering if there is a way to dynamically specify the width of a column that is output by a query, from within that query. Similar to the way you can give a column an alias.
I don't mean doing the "COLUMN FORMAT A??" command.
Can't seem to find an answer to this anywhere.
Cheers
-
you can pad it with spaces if that is what you want
-
I guess that would work, it's a bit crude though.
Thanks anyway
-
Crude? There is a function to do it, research rpad()
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
Hi
Crude ?? :-)
if you can post a small example of what you want then one of us here might help.
regards
Hrishy
-
Hi again,
Here is an example of the problem I'm trying to solve
If i run this query:
Code:
select tablespace_name, file_name
from dba_data_files
order by tablespace_name;
I can adjust the column widths output using the "COLUMN FORMAT A??" command
However if I run the query with column aliases:
Code:
select tablespace_name "Tablespace Name" , file_name "Data File"
from dba_data_files
order by tablespace_name;
All the column formatting I set is ignored and I have very wide columns and an ugly text wrapped table.
How can i get the second query to output the column widths i want?
Thanks
-
Hi
How about
Code:
SQL> set pagesize 500
SQL> column "Tablespace Name" format a30
SQL> column "Data File" format a50
SQL> l
1 select tablespace_name "Tablespace Name" , file_name "Data File"
2 from dba_data_files
3* order by tablespace_name
SQL> /
regards
Hrishy
-
format your column aliases
column "Tablespace Name" format aX
column "Data File" format aX
-
Thanks hrishy and davey23uk, i had no idea a column alias could have it's width formatted like that.
Brilliant, thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|