How to see the CREATE VIEW code for a view in PostgreSQL?

前端 未结 6 628
我寻月下人不归
我寻月下人不归 2020-12-12 13:59

Is there an easy way to see the code used to create a view using the PostgreSQL command-line client?

Something like the SHOW CREATE VIEW from MySQL.

6条回答
  •  死守一世寂寞
    2020-12-12 14:46

    GoodNews from v.9.6 and above, View editing are now native from psql. Just invoke \ev command. View definitions will show in your configured editor.

    julian@assange=# \ev {your_view_names}

    Bonus. Some useful command to interact with query buffer.

    Query Buffer
      \e [FILE] [LINE]       edit the query buffer (or file) with external editor
      \ef [FUNCNAME [LINE]]  edit function definition with external editor
      \ev [VIEWNAME [LINE]]  edit view definition with external editor
      \p                     show the contents of the query buffer
      \r                     reset (clear) the query buffer
      \s [FILE]              display history or save it to file
      \w FILE                write query buffer to file
    

提交回复
热议问题