PostgreSQL笔记

database cluster: a collection of databases managed by a single PostgreSQL server instance

事务(transaction)原子性:from the point of view of other transactions, it either happens completely or not at all. 以下transaction(Alice转账100给Bob),要么都成功,要么失败:

UPDATE accounts SET balance = balance - 100.00
    WHERE name = 'Alice';
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Bob';

标识符(identifier)如果打了双引号,整个引号内视为标识符

UPDATE "my_table" SET "a" = 5;

Key words and unquoted identifiers are case insensitive (都会被理解为小写,比如标识符 FOO, foo, "foo"其实是被解释为同一个.但是"FOO"≠"foo")
UPDATE MY_TABLE SET A = 5;
can equivalently be written as:
uPDaTE my_TabLE SeT a = 5;
因此建议是总是打引号

SQL中的常量
1.用单引号' '引用
2.C-style Escapes: 不支持0x00的转义(即,不能出现Null字符 E'0',不代表不能使用Null Value):

mydb=> SELECT E'asd\0asd';
ERROR:  invalid byte sequence for encoding "UTF8": 0x00

3.Unicode Escapes:
\四位十六进制(four-digit hexadecimal code) or \+六位十六进制.
如果不想用 '\' ,可以 用UESCAPE来替换

U&'d\0061t\+000061'    表示'data'
U&'d!0061t!+000061' UESCAPE '!'    

4.Dollar-quoted String Constants:
为了更readable,PostgreSQL使用$SomeTag$引用 (注:是用来生成常量的,不是用来写标识符的)

$$Dianne's horse$$
$SomeTag$Dianne's horse$SomeTag$

注释

-- This is a standard SQL comment

Alternatively, C-style block comments can be used:

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

图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值