PostgreSQL笔记

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 */
 */

图片描述

相关文章
相关标签/搜索