匹配
- 百分号(%):匹配任意子串
select dept_name from department where building like ‘%Watson’;
(或前缀匹配Watson%)
- 下划线(_):匹配任意单个字符
select dept_name from department where building like ‘W_tson’;
- 假如匹配的字符串中包含特殊字符(例如%和_),那么需要定义
escape
进行转义。like ‘ab\%cd%’ escape ‘\’;
匹配所有以“ad%cd”开头的字符串like ‘ab\\cd%’ escape ‘\’;
匹配所有以“ad\cd”开头的字符串
运算
- 拼接字符串:ad || cd 拼接后:adcd
- upper(), lower() 等等
参考
- 浙江大学 陈岭《数据库系统原理》课程 第四章