database cluster: a collection of databases managed by a single PostgreSQL server instancegit
事務(transaction)原子性:from the point of view of other transactions, it either happens completely or not at all. 如下transaction(Alice轉帳100給Bob),要麼都成功,要麼失敗:app
UPDATE accounts SET balance = balance - 100.00 WHERE name = 'Alice'; UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
標識符(identifier)若是打了雙引號,整個引號內視爲標識符ide
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;
所以建議是老是打引號ui
SQL中的常量
1.用單引號' '引用
2.C-style Escapes: 不支持0x00的轉義(即,不能出現Null字符 E'0',不表明不能使用Null Value):spa
mydb=> SELECT E'asd\0asd'; ERROR: invalid byte sequence for encoding "UTF8": 0x00
3.Unicode Escapes:
\四位十六進制(four-digit hexadecimal code) or \+六位十六進制.
若是不想用 '\' ,能夠 用UESCAPE來替換code
U&'d\0061t\+000061' 表示'data' U&'d!0061t!+000061' UESCAPE '!'
4.Dollar-quoted String Constants:
爲了更readable,PostgreSQL使用$SomeTag$
引用 (注:是用來生成常量的,不是用來寫標識符的)server
$$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 */ */