将列设置为标题长度

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

Oracle : Set column to heading length

问题

我有以下SELECT查询的结果:

  1. CXA|DSTRTG |CB|
  2. ---|---------|--|
  3. 0A2|17-FEB-23|A2|
  4. 0A2|17-FEB-23|A2|
  5. 0A2|17-FEB-23|A2|
  6. 0A2|17-FEB-23|A2|
  7. 0A2|17-FEB-23|A2|

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

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

  1. CXA|DSTRTG |CBXF|
  2. ---|---------|----|
  3. 0A2|17-FEB-23|A2 |
  4. 0A2|17-FEB-23|A2 |
  5. 0A2|17-FEB-23|A2 |
  6. 0A2|17-FEB-23|A2 |
  7. 0A2|17-FEB-23|A2 |

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

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

英文:

I have the following result of a SELECT:

  1. CXA|DSTRTG |CB|
  2. ---|---------|--|
  3. 0A2|17-FEB-23|A2|
  4. 0A2|17-FEB-23|A2|
  5. 0A2|17-FEB-23|A2|
  6. 0A2|17-FEB-23|A2|
  7. 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

  1. CXA|DSTRTG |CBXF|
  2. ---|---------|----|
  3. 0A2|17-FEB-23|A2 |
  4. 0A2|17-FEB-23|A2 |
  5. 0A2|17-FEB-23|A2 |
  6. 0A2|17-FEB-23|A2 |
  7. 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

现在已经调整好了:

  1. SQL> select * from test;
  2. CXA CBXF
  3. --- ----
  4. 0A2 A2
  5. SQL>
英文:

It is the column you must set.

Test case:

  1. SQL> create table test (cxa varchar2(3), cbxf char(2));
  2. Table created.
  3. SQL> insert into test values ('0A2', 'A2');
  4. 1 row created.

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

  1. SQL> select * from test;
  2. CXA CB
  3. --- --
  4. 0A2 A2

Adjust it:

  1. SQL> column cbxf format a4

Now it is OK:

  1. SQL> select * from test;
  2. CXA CBXF
  3. --- ----
  4. 0A2 A2
  5. 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:

确定