Skip to content

Instantly share code, notes, and snippets.

@nastanford
Created June 21, 2013 17:11
Show Gist options
  • Save nastanford/5832732 to your computer and use it in GitHub Desktop.
Save nastanford/5832732 to your computer and use it in GitHub Desktop.
Oracle - List Tables and Columns for each table for an Owner
<basefont face="arial" />
<CFSET REQUEST.DSN = "yourdatasource" />
<CFSET REQUEST.OWNER = "owner" />
<CFQUERY NAME="tables" Datasource="#REQUEST.DSN#" >
SELECT table_name
FROM all_tables
WHERE owner = '#REQUEST.OWNER#'
ORDER BY TABLE_NAME
</CFQUERY>
<cfset tablelist = ""/>
<cfoutput query="tables">
<cfset tablelist = listAppend(tablelist,#tables.table_name#) />
</cfoutput>
<cfoutput>
<cfloop list="#tablelist#" index="item">
<hr /><b>#item#</b><br /><hr />
<cfquery name="columns" datasource="#REQUEST.DSN#" maxrows="1">
SELECT * FROM #item#
</cfquery>
<cfloop list="#columns.columnlist#" index="itemcolumn" >
#itemcolumn#<br />
</cfloop>
</cfloop>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment