On 2016/05/30 12:39 PM, Luca Ferrari wrote:
On Mon, May 30, 2016 at 12:24 PM, Clemens Ladisch <[email protected]> wrote:
This is normal. The ALTER TABLE adds the new column(s) immediately
behind the actual column definition. Inserting a comma before the
comment and the rest of the new column definition in the next line would
be too complex; and in any case the DB cannot know whether the comment
belongs to the column or the table.
Thanks, I was suspecting it.
Is there a "correct" way to annotate SQL schema? Other databases
provides special commands (e.g., PostgreSQL ADD COMMENT), but I don't
see nothing in SQLIte3 syntax except the SQL '--' one.
There is no more-correct way in SQL terms, but there is an option that
works for most of us - simply use /* ... */ style commenting and add it
before the comma, like so:
CREATE TABLE xxx(
...
Col3 INT NOT NULL /* Comment here */,
Col4 TEXT /* Comment two */ NOT NULL,
...etc.
);
Some DB managers even read these as metadata, such as this documentation
example produced by SQLitespeed. You can see the schema SQL that
prompted the detail in there, and if you look at the Numbers table, you
can see the same effect achieved for other objects, like triggers and
Indices:
http://www.sqlc.rifin.co.za/SchemaDocExample2.html
or if you prefer a more contrasting version:
http://www.sqlc.rifin.co.za/SchemaDocExample1.html
Hope that helps!
Ryan
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users