Home > Enterprise >  How to format the output in Oracle 19c SQL Plus?
How to format the output in Oracle 19c SQL Plus?

Time:05-08

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.

CodePudding user response:

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.

  • Related