Creating Comma Seperated Lists
From TekiWiki
This whole wiki has now moved to http://www.springboardsolutions.com/wiki
Go to this page Creating Comma Seperated Lists
| Line 1: | Line 1: | ||
| + | == Comma Seperated Column from a List of Rows == | ||
| + | |||
If you have a table that contains groups of lists - such as the list of columns in tables - and you want to list the columns against their table name on one line rather than across several - such as: | If you have a table that contains groups of lists - such as the list of columns in tables - and you want to list the columns against their table name on one line rather than across several - such as: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| + | ! Owner | ||
! Table Name | ! Table Name | ||
! Column Names | ! Column Names | ||
|- | |- | ||
| + | |EXAMPLE | ||
|ISO_COUNTRY | |ISO_COUNTRY | ||
|CODE,NAME | |CODE,NAME | ||
| + | |||
| + | |- | ||
| + | |SYS | ||
| + | |DBA_SYNONYMS | ||
| + | |OWNER,SYNONYM_NAME,TABLE_OWNER,TABLE_NAME,DB_LINK | ||
|} | |} | ||
| Line 39: | Line 48: | ||
group by owner,table_name | group by owner,table_name | ||
order by owner,table_name | order by owner,table_name | ||
| + | </pre> | ||
| + | |||
| + | == Query Results into Comma Separated Values == | ||
| + | |||
| + | In SQL Plus, a CSV file can be created from the results of a query by adding a | ||
| + | |||
| + | <pre> | ||
| + | rem Creates a CSV file from a SQL query | ||
| + | |||
| + | set colsep , | ||
| + | |||
| + | spool countries.csv | ||
| + | select * from ISO_COUNTRY; | ||
| + | spool off | ||
| + | |||
| + | set colsep " " | ||
</pre> | </pre> | ||