将列设置为标题长度

huangapple go评论56阅读模式
英文:

Oracle : Set column to heading length

问题

我有以下SELECT查询的结果:

CXA|DSTRTG   |CB|
---|---------|--|
0A2|17-FEB-23|A2| 
0A2|17-FEB-23|A2| 
0A2|17-FEB-23|A2|
0A2|17-FEB-23|A2|
0A2|17-FEB-23|A2|

列CB的实际名称应该是CBXF,并且数据的长度是CHAR(2),因此结果基于此被截断。

我想要选择的结果如下所示:

CXA|DSTRTG   |CBXF|
---|---------|----|
0A2|17-FEB-23|A2  |
0A2|17-FEB-23|A2  |
0A2|17-FEB-23|A2  |
0A2|17-FEB-23|A2  |
0A2|17-FEB-23|A2  |

我想要自动设置它(所有结果都适应列长度而不是数据长度)。

我尝试增加参数LINESIZE,LONG...,但没有成功。

英文:

I have the following result of a SELECT:

CXA|DSTRTG   |CB|
---|---------|--|
0A2|17-FEB-23|A2| 
0A2|17-FEB-23|A2| 
0A2|17-FEB-23|A2|
0A2|17-FEB-23|A2|
0A2|17-FEB-23|A2|

The column CB name is actually CBXF , and the length of data is CHAR(2) so the result is truncated based on this.
I want the result of the select to be like this

CXA|DSTRTG   |CBXF|
---|---------|----|
0A2|17-FEB-23|A2  |
0A2|17-FEB-23|A2  |
0A2|17-FEB-23|A2  |
0A2|17-FEB-23|A2  |
0A2|17-FEB-23|A2  |

I want to set it automatically (all the results fit the column length not the data length)

I tried increasing the parameters LINESIZE , LONG..., didn't work

答案1

得分: 2

现在已经调整好了:

SQL> select * from test;

CXA  CBXF
---  ----
0A2  A2

SQL>
英文:

It is the column you must set.

Test case:

SQL> create table test (cxa varchar2(3), cbxf char(2));

Table created.

SQL> insert into test values ('0A2', 'A2');

1 row created.

Current output (the last column name is missing some letters):

SQL> select * from test;

CXA CB
--- --
0A2 A2

Adjust it:

SQL> column cbxf format a4

Now it is OK:

SQL> select * from test;

CXA CBXF
--- ----
0A2 A2

SQL>

huangapple
  • 本文由 发表于 2023年7月17日 17:52:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76703277.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定