{"id":100,"date":"2017-04-07T12:54:12","date_gmt":"2017-04-07T12:54:12","guid":{"rendered":"http:\/\/www.yohz.com\/blogs\/?p=100"},"modified":"2017-04-14T08:42:53","modified_gmt":"2017-04-14T08:42:53","slug":"documenting-your-postgresql-database","status":"publish","type":"post","link":"https:\/\/www.yohz.com\/blogs\/2017\/04\/07\/documenting-your-postgresql-database\/","title":{"rendered":"Documenting your PostgreSQL database"},"content":{"rendered":"<p>PostgreSQL has a pretty nifty feature to add comments to database objects, using the <a href=\"https:\/\/www.postgresql.org\/docs\/9.6\/static\/sql-comment.html\">COMMENT<\/a> function. \u00a0You can pretty much add comments to almost any objects, like tables, view, foreign keys, constraints, columns, etc.<\/p>\n<p>You add a comment using the COMMENT ON &#8230; function, then retrieve the comment using the <a href=\"https:\/\/www.postgresql.org\/docs\/9.5\/static\/functions-info.html\">obj_description<\/a> function for most objects. \u00a0For columns, you&#8217;ll need to use the <a href=\"https:\/\/www.postgresql.org\/docs\/9.5\/static\/functions-info.html\">col_description<\/a> function.<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-102\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_01.png\" alt=\"\" width=\"800\" height=\"600\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_01.png 800w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_01-300x225.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_01-768x576.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_01-150x113.png 150w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>All this is rather tedious if you plan to add\/remove comments for a lot of objects. \u00a0To make this task easier, we have recently released a free product, <a href=\"http:\/\/www.yohz.com\/pgc_details.htm\">PgComment<\/a>, downloadable <a href=\"http:\/\/www.yohz.com\/downloads\/pgcomment\/PgCommentSetup.zip\">here<\/a>. \u00a0With <a href=\"http:\/\/www.yohz.com\/pgc_details.htm\">PgComment<\/a>, you just connect to your database and the application will list out all the comments attached to your tables, columns, indexes, views, sequences, domains, and functions.<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-110\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_03.png\" alt=\"\" width=\"908\" height=\"626\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_03.png 908w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_03-300x207.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_03-768x529.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_03-150x103.png 150w\" sizes=\"(max-width: 908px) 100vw, 908px\" \/><\/p>\n<p>You can then easily modify the comments, and apply them to the database. \u00a0Changes are cached, and sent to the server in a single batch, allowing for faster editing locally. \u00a0With the schema displayed in a hierarchical tree, you get an overview of what&#8217;s been commented and what has not. \u00a0This makes it so much easier to document your PostgreSQL database.<\/p>\n<p>Another feature of PgComment is that you can view the properties of your database objects. \u00a0For tables, you can see details like the owner, total size, index size, estimated rows etc.<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-108\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_04.png\" alt=\"\" width=\"800\" height=\"626\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_04.png 800w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_04-300x235.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_04-768x601.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_04-150x117.png 150w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>For indexes, you can see details like the index definition, index size, and various other properties.<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-109\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_05.png\" alt=\"\" width=\"800\" height=\"625\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_05.png 800w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_05-300x234.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_05-768x600.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2017\/04\/pgcomment_05-150x117.png 150w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Displaying these properties should help you write better comments for your objects.<\/p>\n<p>If you want to generate PDF or HTML reports of your PostgreSQL database schema, take a look at\u00a0<a href=\"http:\/\/www.yohz.com\/dbdoc_details.htm\">DB Doc<\/a>. \u00a0With <a href=\"http:\/\/www.yohz.com\/dbdoc_details.htm\">DB Doc<\/a>, you can generate customizable PDF and HTML schema reports in just a few clicks.<\/p>\n<div class=\"fcbkbttn_buttons_block\" id=\"fcbkbttn_left\"><div class=\"fcbkbttn_like \"><fb:like href=\"https:\/\/www.yohz.com\/blogs\/2017\/04\/07\/documenting-your-postgresql-database\/\" action=\"like\" colorscheme=\"light\" layout=\"button\"  size=\"small\"><\/fb:like><\/div><div class=\"fb-share-button  \" data-href=\"https:\/\/www.yohz.com\/blogs\/2017\/04\/07\/documenting-your-postgresql-database\/\" data-type=\"button\" data-size=\"small\"><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>PostgreSQL has a pretty nifty feature to add comments to database objects, using the COMMENT function. \u00a0You can pretty much add comments to almost any objects, like tables, view, foreign keys, constraints, columns, etc. You add a comment using the COMMENT ON &#8230; function, then retrieve the comment using the obj_description function for most objects. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[6,22],"tags":[3,23],"_links":{"self":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/100"}],"collection":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":4,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":111,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/100\/revisions\/111"}],"wp:attachment":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}