I want to add data description (information about what each column represents, and some additional information) to my SQL database. It is similar to the label data
/label variable
command in Stata, and the var.labels
attribute of dataframes in R (requires the readstata13
package, can be accessed via varlabel(df)
).
Here's an example of what I wanted (taken from the Stata manual):
There is a variable label on the variable id
to explain what is stored in that column.
I want to know, is this possible in standard SQL (I am using SQLite via the RSQLite
package)?
For example, if I want to read/write the labels of a dataframe in R, I can do
library("readstata13")
# df is a dataframe with three columns
# Get labels of all columns
varlabel(df)
# Get label of one specific column
varlabel(df, var.name = "variable_name")
# Set label for all columns
varlabel(df) <- c("label1", "label2", "label3")
# Set label for one specific column
varlabel(df, var.name = "variable_name") <- "This is a label"
I do find this question on Stack Overflow: Add Description From Excel File to Columns description in SQL, which uses the sp_addextendedproperty
, but it seems to be an SQL Server-only feature (which, unfortunately, is not a possible option for me).