What's the character for comments in postgres?
SELECT * FROM my_table # pound sign produces a syntax error
Thank you cababunga, the following appears to work:
SELECT * FROM my_table -- this is my comment
But this does not work:
\dt jvcurve_thin.jvcurve_results -- my comment #2
\dt: extra argument "--" ignored
Syntax Using /* and */ symbols In PostgreSQL, a comment that starts with /* symbol and ends with */ and can be anywhere in your SQL statement. This method of commenting can span several lines within your SQL.
Special character symbols are characters with a pre-defined syntactic meaning in PostgreSQL. They are typically disallowed from being used in identifier names for this reason, though as mentioned in the section on quoted identifiers, this restriction can usually be worked around with quotes if need be.
In PostgreSQL, the dollar-quoted string constants ($$) is used in user-defined functions and stored procedures. In PostgreSQL, you use single quotes for a string constant like this: select 'String constant'; When a string constant contains a single quote ('), you need to escape it by doubling up the single quote.
CHAR(n) is used for data(string) with a fixed-length of characters with padded spaces. In case the length of the string is smaller than the value of “n”, then the rest of the remaining spaces are automatically padded. Similarly for a string with a length greater than the value of “n”, PostgreSQL throws an error.
According to PostgreSQL documentation, there are both the inline and the block style comments.
The inline style:
SELECT 23 AS test -- this is just a test
The block style:
/* The following is a very * non-trivial SQL code */ SELECT 42 AS result
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With