Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading