简体   繁体   English

如何格式化Oracle 19c SQL Plus中的output?

[英]How to format the output in Oracle 19c SQL Plus?

在此处输入图像描述

Hi I am trying to format this select's output to look like a table with columns not on on top of each other, but one next to each other and the values to be under the correct column.您好,我正在尝试将此选择的 output 格式化为看起来像一个表格,其中的列不是彼此重叠,而是彼此相邻,并且值位于正确的列下。

For the vast majority of situations, you'd be better off using a GUI like SQL Developer to run your queries which will automatically format results in a visually pleasing manner.对于绝大多数情况,您最好使用像 SQL Developer 这样的 GUI 来运行您的查询,这将以一种视觉上令人愉悦的方式自动格式化结果。

In SQL*Plus , however, you can go for each column and identify the number of characters you want to be used in your output. I'm guessing your output window is 80 characters wide so you'd want the total width allocated to all the columns to be less than 80 characters.但是,在SQL*Plus中,您可以为每一列设置 go 并确定要在 output 中使用的字符数。我猜您的 output window 是 80 个字符宽,因此您希望将总宽度分配给所有列少于 80 个字符。 Something like this would appear to work (at least for the data you're showing) but would wrap if you have longer values than I've guessed in some columns.这样的事情似乎可行(至少对于您显示的数据而言)但如果您的值比我在某些列中猜测的更长,则会换行。 You might or might not be OK with, say, a longer constraint name being displayed across two rows你可能会也可能不会接受,比如说,在两行中显示一个更长的约束名称

column owner format a15
column constraint_name format a20
column table_name format a15
column column_name format a15
column position format 999

Remember that SQL*Plus formatting commands were originally designed to produce reports that were spooled to physical printers full of that lovely white and green bar paper not for developers running random ad hoc queries.请记住, SQL*Plus格式化命令最初设计用于生成报告,这些报告被假脱机发送到装满可爱的白色和绿色条形纸的物理打印机,而不是供开发人员运行随机即席查询。 That's what GUIs were designed for.这就是 GUI 的设计目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM