0

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?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Josep
  • 495
  • 2
  • 6
  • 16
  • 2
    Do you have a question, or would you like us to do your job for you? – Neville Kuyt Feb 07 '13 at 09:46
  • 2
    Neville, I didn't ask anyone to come to my office at 8 am, nor to edit all the scripts, nor to do anything I already know how to do. I've just got blocked at this particular point and I'm asking for help. This is what Stack Overflow is for. So, I want to do my job, I don't ask anyone to do it for me. I just have a question. – Josep Feb 07 '13 at 10:25
  • 2
    @Josep - I totally agree! Your question was simple enough to understand if someone had taken the time to bother reading it. – Dave Richardson Feb 07 '13 at 12:04

1 Answers1

3

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.

Community
  • 1
  • 1
Xavi López
  • 27,550
  • 11
  • 97
  • 161