I would like to add custom attributes to a MySQL table which I can read via php.
These attributes are not to interfere with the table itself – they are primarily accessed by php code during code generation time and these attributes HAVE to reside in the DB itself.
Something similar in concept to .NET reflection.
Does MySQL support anything like this?
Thanks.
When you
CREATEorALTERa table, you can addCOMMENTS– one for the table as a whole and one for each column. To retrieve these comments, you can query the databaseINFORMATION_SCHEMA, specifically the columnsINFORMATION_SCHEMA.COLUMNS.COLUMNS_COMMENTandINFORMATION_SCHEMA.TABLE.TABLE_COMMENTS.INFORMATION_SCHEMAprovides a lot of metadata about your databases, including the data provided byDESCRIBEstatements. Any user who has read access to a certain table or column can read the respective metadata fromINFORMATION_SCHEMA, but cannot read metadata about tables they do not have read access for.It looks natural to store your custom metadata in
INFORMATION_SCHEMA, but it is not as flexible as you might need it because you can store only oneCOMMENTper column. If this is to restrictive for your purpose or you need to update the data regularly, you should follow @Dark Falcon and create an additional table.