在標准 SQL 中,字符串使用的是單引號。
如果字符串本身也包括單引號,則使用兩個單引號(注意,不是雙引號,字符串中的雙引號不需要另外轉義)。
如:
insert into tableA (id, name) values (1, 'abc');
insert into tableA (id, name) values (2, '"abc');
insert into tableA (id, name) values (3, 'a''bc');
select * from tablea;
輸出:
+----+------+
| id | name |
+----+------+
| 1 | abc |
| 2 | "abc |
| 3 | a'bc |
+----+------+
3 rows in set
mysql中也允許用雙引號表示字符串,但是這不是標准是擴展,最好不用,oracal中只允許用單引號。