めんどくさくてもコメントは必須。
データベース、スキーマ、テーブル、列のすべてにコメントはつけましょう。
test=> COMMENT ON DATABASE test IS 'テスト用データベース'; COMMENT test=> COMMENT ON SCHEMA testschema IS 'テスト用スキーマ'; COMMENT test=> COMMENT ON TABLE testschema.testtable IS 'テスト用テーブル'; COMMENT
たとえば、testschemaスキーマのtesttableが以下のように定義されている場合、
test=> CREATE TABLE testschema.testtable( test(> id integer, test(> name varchar(30), test(> age integer DEFAULT 0 test(> );
コメントは以下のようにする。
test=> COMMENT ON COLUMN testschema.testtable.id IS 'ID'; COMMENT test=> COMMENT ON COLUMN testschema.testtable.name IS '名前'; COMMENT test=> COMMENT ON COLUMN testschema.testtable.age IS '年齢'; COMMENT
確認すると以下のようになる。
test=> \d+ testschema.testtable Table "testschema.testtable" Column | Type | Modifiers | Description
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-