Comment character/characters in postgres / postgresql / psql?

前端 未结 5 787
难免孤独
难免孤独 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:23

    From the official documentation: PostgreSQL Comments.

    A comment is a sequence of characters beginning with double dashes and extending to the end of the line, e.g.:

    -- This is a standard SQL comment
    

    Alternatively, C-style block comments can be used:

    /* multiline comment  * with nesting: /* nested block comment */  */
    

    where the comment begins with /* and extends to the matching occurrence of */. These block comments nest, as specified in the SQL standard but unlike C, so that one can comment out larger blocks of code that might contain existing block comments.

    A comment is removed from the input stream before further syntax analysis and is effectively replaced by whitespace.

    And it has been supported the same way ever since dark ages (version 7.0).

提交回复
热议问题