為什麼 MySQL 在 INSERT INTO 中拒絕字串的管道('|')字元?
若要將管道(|)字元插入 INSERT INTO 中的字串,我們首先看一個示例並建立一個表。建立表的查詢如下
mysql> create table PipeInsertDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserPassword varchar(100) -> ); Query OK, 0 rows affected (0.52 sec)
使用 insert 命令在表中插入一些記錄。查詢如下 −
mysql> insert into PipeInsertDemo(UserPassword) values('John123|');
Query OK, 1 row affected (0.15 sec)
mysql> insert into PipeInsertDemo(UserPassword) values('|123456CarolTaylor');
Query OK, 1 row affected (0.13 sec)
mysql> insert into PipeInsertDemo(UserPassword) values('Adam|345Smith');
Query OK, 1 row affected (0.20 sec)使用 select 語句顯示錶中的所有記錄。查詢如下 −
mysql> select *from PipeInsertDemo;
以下是輸出
+--------+--------------------+ | UserId | UserPassword | +--------+--------------------+ | 1 | John123| | | 2 | |123456CarolTaylor | | 4 | Adam|345Smith | +--------+--------------------+ 3 rows in set (0.00 sec)
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP