oracle SQLPLUS 输出:如何自动获得每列的最小列宽?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10382390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQLPLUS output: How to automatically get minimal column width for each column?
提问by fenerlitk
I tried set linewidth, but that wasn't my intention, is there anyway to shrink each columns width to the minimum that will fit the values? or auto substring each column so that they all fit in the screen?
我尝试设置线宽,但这不是我的意图,无论如何将每列的宽度缩小到适合这些值的最小值?或自动子字符串每列,以便它们都适合屏幕?
thanks.
谢谢。
采纳答案by psaraj12
You can use
您可以使用
COLUMN columnname FORMAT An
for Char, VARCHAR2 (VARCHAR), LONG columns
对于 Char、VARCHAR2 (VARCHAR)、LONG 列
where nis the the desired display width and columnnameis a column of a table
其中n是所需的显示宽度,而columnname是表格的一列
for example
例如
COLUMN title FORMAT a40
For different datatype like Number and other options you can refer the below link
对于不同的数据类型,如 Number 和其他选项,您可以参考以下链接
http://ss64.com/ora/syntax-sqlplus-fmt.html
http://ss64.com/ora/syntax-sqlplus-fmt.html
The big limitation is that you can't set an fixed width for all VARCHAR2 columns, only for specific ones.
最大的限制是您不能为所有 VARCHAR2 列设置固定宽度,只能为特定列设置。