在PostgreSQL数据库中使用$$作为字符串的引用符号

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/msdnchina/article/details/79965211
参考自:https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html
中的4.1.2.4. Dollar-quoted String Constants部分。


大概意思是:$highgolei$t$highgolei$中的 highgolei是Tag,这Tag可以不要,于是就成了dollar dollar t dollar dollar ,这个dollar dollar t dollar dollar就等于't'
这个Tag啥用?没自己研究。。。

postgres=# select count(*) from pg_class where relkind='t';
 count 
-------
    19
(1 row)


postgres=# select count(*) from pg_class where relkind=$$t$$;
 count 
-------
    19
(1 row)


postgres=# select count(*) from pg_class where relkind=$SomeTag$Dianne's horse$SomeTag$;
 count 
-------
     0
(1 row)


postgres=# select count(*) from pg_class where relkind=$SomeTag$t$SomeTag$;
 count 
-------
    19
(1 row)
postgres=# select count(*) from pg_class where relkind=$highgo$t$highgo$;
 count 
-------
    19
(1 row)


postgres=# select count(*) from pg_class where relkind=$highgolei$t$highgolei$;
 count 
-------
    19
(1 row)


postgres=# select count(*) from pg_class where relkind=$highgo-lei$t$highgo-lei$;
ERROR:  syntax error at or near "$"
LINE 1: select count(*) from pg_class where relkind=$highgo-lei$t$hi...
                                                    ^
postgres=# 



阅读更多

没有更多推荐了,返回首页