Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comment character/characters in postgres / postgresql / psql?

Tags:

postgresql

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

like image 858
russian_spy Avatar asked Nov 24 '10 22:11

russian_spy


People also ask

How do I write a comment in PostgreSQL?

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.

How do you handle special characters in PostgreSQL?

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.

What is $$ in PostgreSQL?

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.

What is char data type in PostgreSQL?

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.


1 Answers

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 
like image 88
Tregoreg Avatar answered Sep 22 '22 15:09

Tregoreg