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.

3
  • by actual view text, you mean definition? stackoverflow.com/questions/14634322/… Commented Apr 4, 2016 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);? Commented Apr 4, 2016 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 <view_name> 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. Commented Apr 4, 2016 at 13:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.