如何格式化Oracle 19C SQL Plus中的输出?

发布于 2025-01-27 09:04:13 字数 154 浏览 2 评论 0原文

“在此处输入映像说明”

嗨,我正在尝试格式化此select的输出,看起来像一个表,看起来像一张列,每个列都不在每个上面另一个,但一个彼此相邻,值在正确的列下。

enter image description here

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缺⑴份安定 2025-02-03 09:04:13

对于绝大多数情况,您最好使用SQL开发人员(例如SQL开发人员)运行查询,这将自动以视觉上令人愉悦的方式产生查询。

但是,在sql*plus中,您可以使用每列并确定要在输出中使用的字符数。我猜您的输出窗口是80个字符宽,因此您希望将所有列的总宽度分配给所有小于80个字符。这样的事情似乎可以工作(至少对于您显示的数据),但是如果您的值比我在某些列中猜测的更长的值,则可以包装。您可能会或可能不同意,例如,在两个行上显示一个更长的约束名称,

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

请记住,sql*plus格式命令最初是设计为生产被载入物理打印机的报告的,充满了该可爱的物理打印机白色和绿色条形纸不适合运行随机临时查询的开发人员。这就是Guis的设计目的。

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.

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. 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. That's what GUIs were designed for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文