为什么 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