Oracle metadata to store column titles/labels
Does Oracle have a column metadata for storing its printable friendly label?
Say I have a column named prodDesc.
I would like to be able to pull a column label such as "Product Description"
for use in end reports & web pages. I plan to utilize the column size meta data as well so that when I generate an html form I can dynamically set the size
and maxlength
parameters for the input textbox.
I realize I can use the AS
keyword, but then I need to update this in every sql statement but I'd rather maintain column labels in one location.
A work around thought was to duplicate every table naming each with an appended _label and then each would have just one row to store column labels. But this seems excessive.
tblProduct
tblProduct_label <--- same structure as tblProduct but the values
BTW, This is for 开发者_JAVA技巧a java web application with an oracle backend.
EDIT: this is an example xml file I am already maintaining for all my db tables...
<schema>
<tableName>xtblPersonnel</tableName>
<tableTitle>Personnel</tableTitle>
<tableConstraints></tableConstraints>
<column>
<name>PID</name>
<type>VARCHAR2</type>
<size>9</size>
<label>Badge ID</label>
</column>
<column>
<name>PCLASS</name>
<type>VARCHAR2</type>
<size>329</size>
<label>Classification</label>
</column>
<schema>
Since this is a UI issue, it's usually handled in the presentation layer by keeping maps of column name/label pairs (usually one map per language). You pass the column name (or a key composed of table name+column name, if necessary) in to the map and get the label out. If you want to keep them in the database, you can create a table with columns for the table name, column name, language ID and label, then create your maps on startup or lazily initialize them as needed.
You could use the information in user_col_comments and user_tab_comments, which is stored as a result of issuing "COMMENT ON COLUMN..." or "COMMENT ON TABLE..." SQL.
精彩评论