Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of MySQL's \G in Oracle's SQL*Plus

Tags:

oracle

sqlplus

In Oracle's SQL*Plus, the results of a SELECT are displayed in a tabular manner. Is there a way to display a row in a key-value manner (like MySQL's \G option)?

The database I am working on (the schema is not defined by me) has a bunch of columns named e.g. YN_ENABLED (YN = yes no) which are CHAR(1). So when I do a query I get a result like

ID_MYTABLE   Y Y Y
------------ - - -
3445         Y N Y

So it's not really clear which columns have which values (without having the schema open in another window).

like image 874
Adrian Smith Avatar asked Nov 16 '10 10:11

Adrian Smith


1 Answers

Not built in to SQL PLus, but Tom Kyte has provided a procedure called print_table that does this. You would run it like this:

SQL> exec print_table ('select * from mytable where id_mytable=123');

And see results like:

ID_MYTABLE      : 123
YN_ENABLED      : Y
YN_SOMETHING    : N
...
like image 129
Tony Andrews Avatar answered Sep 26 '22 01:09

Tony Andrews