If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Does MySQL allow user defined table attributes?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-18-08, 15:26
nickweavers nickweavers is offline
Registered User
 
Join Date: Jan 2005
Posts: 15
Does MySQL allow user defined table attributes?

I have been using MySQL for a while now and for some reason have always been under the impression that it is good practice to use the same style of names for fields as you would for program variables (eg date_last_updated). I'm not sure where I got this idea or if it is correct. I guess it makes queries easier to write and shorter in length. Anyway, doing things this way usually means that when you use PHP to generate htlml to show the contents of a table, you end up having to add "nice" column names (such a "Date last updated") as you can't rely on the actual fields names being easily understood by people viewing the report.

This made me wonder whether MySQL had anywhere else you could store the plain english heading names on the tables. Maybe user defined attributes or meta data or something.

Can anyone advise?
TIA.
Reply With Quote
  #2 (permalink)  
Old 02-18-08, 17:00
by0nder by0nder is offline
Registered User
 
Join Date: Jan 2008
Location: Kingdom of Sweden
Posts: 11
Why not use aliases in the queries?

SELECT date_last_updated AS 'Date last updated' FROM table;
Reply With Quote
  #3 (permalink)  
Old 02-18-08, 18:03
nickweavers nickweavers is offline
Registered User
 
Join Date: Jan 2005
Posts: 15
Thank you for your suggestion.

I think it would have been more helpful if I had put my query in context.

I am trying to use the gridEditor in the Extjs javascript library to show my tables and would like to build JSON object literals for it which contain this sort of information.

I think maybe using long field names may be the solution for me since I also want to know the field width and data type too, and I just discovered "SHOW COLUMNS FROM myTable" which will give me all of these.
Reply With Quote
  #4 (permalink)  
Old 02-18-08, 18:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
you have just discovered SHOW?

have a look at the INFORMATION_SCHEMA views, they will knock your socks off
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On