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

◇◆丶佛笑我妖孽 提交于 2019-12-04 02:50:56

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
...

I know your question is about SQL*PLus, but you might be interested to know that Oracle's SQL Developer can do this. The feature can be used by right clicking on the Query Results and selecting "Single Record View...".

Here's a trick that may do in a pinch if you don't want to (or cannot) install a new procedure on your server:

  1. Select the row (or rows) of interest in the Oracle SQL Developer query results window.
  2. Use shift-control-c in Oracle SQL Developer to copy the rows and headers to the clipboard.
  3. Paste into your favorite spreadsheet (e.g., MS Excel). Now you have records in rows.
  4. Copy the rows that you just pasted into the spreadsheet
  5. Use the "Paste Special - Transpose" feature of your spreadsheet program to paste the values into a new spreadsheet. Now your records should be in columns.

Coming in late, but I found this

SQL> select * from xmltable('ROWSET/ROW/*' passing xmltype(cursor(select * from emp where rownum = 1
)) columns name varchar2(30) path 'node-name(.)', value varchar2(30) path '.');

Found here

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!