mysql> desc tester;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| name | varchar(20) | YES | | NULL | |
| age | int(10) | YES | | NULL | |
| email | varchar(20) | YES | UNI | NULL | |
+-------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
mysql> prepare adduser from 'insert into tester (name,age,email) values (?,?,?)';
Query OK, 0 rows affected (0.00 sec)
Statement prepared
mysql> set @name='jyd',@age=5,@email='962584902@qq.com';
Query OK, 0 rows affected (0.00 sec)
mysql> execute adduser using @name,@age,@email;
Query OK, 1 row affected (0.02 sec)
mysql> select * from tester;
+----+------+------+------------------+
| id | name | age | email |
+----+------+------+------------------+
| 1 | c | 12 | c7@q.com |
| 2 | c | 13 | c8@q.com |
| 3 | c | 14 | c9@q.com |
| 4 | c | 15 | c10@q.com |
| 5 | b | 15 | c11@q.com |
| 6 | b | 15 | c12@q.com |
| 7 | b | 15 | c13@q.com |
| 8 | b | 15 | c14@q.com |
| 9 | b | 15 | c15@q.com |
| 10 | jyd | 5 | 962584902@qq.com |
+----+------+------+------------------+
10 rows in set (0.00 sec)
mysql> set @name='jyd11',@age=52,@email='9625811@qq.com';
Query OK, 0 rows affected (0.00 sec)
mysql> execute adduser using @name,@age,@email;
Query OK, 1 row affected (0.02 sec)
mysql> select * from tester;
+----+-------+------+------------------+
| id | name | age | email |
+----+-------+------+------------------+
| 1 | c | 12 | c7@q.com |
| 2 | c | 13 | c8@q.com |
| 3 | c | 14 | c9@q.com |
| 4 | c | 15 | c10@q.com |
| 5 | b | 15 | c11@q.com |
| 6 | b | 15 | c12@q.com |
| 7 | b | 15 | c13@q.com |
| 8 | b | 15 | c14@q.com |
| 9 | b | 15 | c15@q.com |
| 10 | jyd | 5 | 962584902@qq.com |
| 11 | jyd11 | 52 | 9625811@qq.com |
+----+-------+------+------------------+
11 rows in set (0.00 sec)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。