Mysql Literal(文字,既常量)

字符串

单引号,双引号都可以表示字符
sql 'a string' "another string"

转义字符

Escape SequenceCharacter Represented by Sequence
\0An ASCII NUL (X’00’) character
A single quote (’) character
"A double quote (") character
\bA backspace character
\nA newline (linefeed) character
\rA carriage return character
\tA tab character
\ZASCII 26 (Control+Z); see note following the table
\A backslash () character
%A % character; see note following the table
_A _ character; see note following the table

例子

SELECT 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello'; 语句中包含引号
SELECT "hello", "'hello'", "''hello''", "hel""lo", "\"hello"; 语句中包含引号
SELECT 'This\nIs\nFour\nLines';

数字

时间

十六进制

SELECT X'4D7953514C', CHARSET(X'4D7953514C');

二进制

SELECT b'1000001', CHARSET(b'1000001');

布尔

SELECT TRUE, true, FALSE, false;
-> 1, 1, 0, 0

null

SELECT * FROM my_table WHERE phone = NULL;

参考:
https://dev.mysql.com/doc/refman/8.0/en/literals.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值