0

PostgreSQL does not allow to store inline comments in view's SQL definition, because the CREATE VIEW statement is parsed, and then analyzed to see what table and other database objects are referenced, and then the analyzed parse-tree is saved.

However in our application we have designed one process which uses the tags that we mention within comments as part of CREATE VIEW definition. Things were going on good in Oracle database as it stored inline comments also. During migration we are unable to port one of our functionality which have dependency on comments in View in Postgres it didn't save the comments.

Do we have anyway to get the actual VIEW text in Postgres db.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • by actual view text, you mean definition? http://stackoverflow.com/questions/14634322/how-to-see-the-create-view-code-for-a-view-in-postgresql – Adam Silenko Apr 04 '16 at 13:37
  • 1
    How about something like `CREATE VIEW my_view AS SELECT 1 AS col; COMMENT ON VIEW my_view IS 'This is my custom comment.'; SELECT obj_description('public.my_view'::regclass);`? – Lukasz Szozda Apr 04 '16 at 13:41
  • Thanks for suggestions. Earlier also I checked that link but it didn't help. About the second option, we have inserted comments within the text i.e. Create or replace view as /* comment 1*/ select union /*comment 2 */ select; So we won't be able to use COMMENT statement. We are trying to move our application from Oracle to Postgres db. In Oracle db it preserves full VIEW creation text in the dictionary table. But in Postgres it stores parsed represenation of the script. Can we get the original VIEW creation script in Postgres DB. – vikschandel Apr 04 '16 at 13:47

0 Answers0