Reputation: 217
We currently have tables full of sensor readings. An example of the column names would be:
However, as you can see it is not very descriptive, but we need these to be this way as it matches the sensor ids themselves. I was wondering if there is a neat solution to adding the description of the columns such as:
I thought of having a table in the database with the following columns:
However, it just doesn't feel like a very neat solution.
Does postgres have a functionality of adding a description of the column in one of the pg tables, or in the back end of the table itself somehow?
Edit:
The question has been answered below. If anyone is wondering how to retrieve the comments this page is very useful
https://www.developerfiles.com/adding-and-retrieving-comments-on-postgresql-tables/
Upvotes: 3
Views: 2037
Reputation:
You can attach a comment to a column:
comment on column the_table.ao_1
is 'This refers to a temperature sensor that is at the beginning of the outlet';
comment on column the_table.ao_2
is 'This refers to a temperature sensor that is at the end of the outlet';
A good SQL client will then display those columns together with the table definitions.
You can do the same for the table itself:
comment on table the_table is 'This tables stores sensor readings';
This doesn't stop at tables and columns. You can attach a comment to nearly everything in the database.
Upvotes: 7