Reputation: 535
I want a script that inserts table comments and column comments. Said script must be unique and run satisfactorily both on Oracle and MySQL. Furthermore, I prefer it to be written in Standard SQL.
This is how I do it now. But it does not work on MySQL.
comment on table F_Transaction
is 'Fact table for system transactions';
comment on column F_Transaction.Transaction_Date
is 'Date in which the transaction took place';
What SQL construction should I use to achieve my purpose?
Upvotes: 2
Views: 3255
Reputation: 27880
The standards do not seem to define any way to define table or column comments (looks like they don't even mention them). So, the syntax for comments on tables/columns can vary from one DBMS to another.
It seems that a number of DBMS agree with Oracle's COMMENT ON
syntax (see Oracle create table with column comments).
With MySQL it's necessary to specify the comments along with the table/column definition (in CREATE TABLE
or ALTER TABLE
sentences). See this related question: Alter MYSQL Table To Add Comments on Columns.
Upvotes: 4