Quick Tip: Getting Hold of Field Names from a Table

 
Jun 12, 2000
Michael Smith, of TeraTech, Inc., forwards the following tip to us, based on an e-mail exchange with Peter Robertson and "cfaussie" list, on getting hold of field names from a table.

Michael originally posted: "You can get this info [field names] from the system data dictionary tables built into most databases. Try looking for tables with names such as syscolumns or systables in your Master database. Good luck."

Peter wrote back: "... I've had a cruise around PostreSQL's system tables, and the information is there, and could be retrieved. It looks as though it would be a bit messy, and may be difficult to generalize. I also have doubts that if I did a dump and re-build of a database [whether] the object IDs (internal keys) would be preserved; something I would need to investigate.

"My solution is to take another tack and define database tables in a definition table, then use this as a generator when I build the tables themselves. The row order will determine the table field order of the generated tables, and I will use the definition table as a reference whenever I need to generate related forms, etc. ... round about, I know, but I'm happy with this for a number of reasons."

Michael responded: "I have done that too on some apps -- you get more control and can add your own extra fields to the data dictionary. You can run a query to add any new fields and flag deleted ones from the master data dictionary tables in the database... It is a powerful method."

Source: "CFAussie" List


Privacy | FAQ | Site Map | About | Guidelines | Contact | Advertising | What is ColdFusion?
House of Fusion | ColdFusion Jobs | Blog of Fusion | AHP Hosting