Comment character/characters in postgres / postgresql / psql?

前端 未结 5 785
难免孤独
难免孤独 2020-12-24 10:54

What\'s the character for comments in postgres?

SELECT * FROM my_table     # pound  sign produces a syntax error

Thank you cababunga, the f

5条回答
  •  臣服心动
    2020-12-24 11:44

    It doesn't look like psql supports traditional end-of-line -- comments in its psql-specific "slash commands."

    However, if you're okay with the end-of-line comments being displayed on execution, using \echo seems to be a valid work-around. For example:

    \dt jvcurve_thin.jvcurve_results   \echo my comment #2
    

    The "double slash" separator meta-command looks like another possibility (and without the side effect of echoing). Begin a new command with it and immediately start a -- comment:

    \dt jvcurve_thin.jvcurve_results   \\ -- my comment #2
    

    Finally, switching to the shell and adding a shell comment seems like another possibility:

    \dt jvcurve_thin.jvcurve_results   \! # my comment #2
    

提交回复
热议问题