oracle - Output key, value pairs with sqlplus -


i using sqlplus output content of table :

select * my_table; 

the output similar :

id ------------- field1 ---------------- field2 ---------------- someid field 1 content field 2 content 

i tried many combinations of page formatting options. can format output in table setting head, pages, termout, echo, feed , linesize.

but output values in (key, value) fashion, :

id = someid field1 = field 1 content field2 = field 2 content 

delimiter , formatting not important, long have 1 column per line.

is possible using sqlplus ? avoid scripting this. on particular machine (an appliance can't install anythin on) have bash, perl , python 2.4.

i don't know of sqlplus settings format, can brute force. should work:

select   'id = ' || id || chr(10) ||   'field1 = ' || field1 || chr(10) ||   'field2 = ' || field2 my_table 

addendum op asked if it's possible make chr(10) colsep value in sqlplus. thought "no way", stumbled across this stackoverflow answer on how set colsep tab, , modified chr(10). don't quite understand how/why works, work:

col newline# new_value newline noprint select chr(10) newline# dual; set colsep "&newline" 

Comments