sql 基础--mysql 5 (9)

16 插入 insert into table values()

mysql> insert into pw_price values (5,5000,'cai');
Query OK, 1 row affected (0.03 sec)

mysql> select * from pw_price;\
+-----+-------+------------+
| uid | price | first_name |
+-----+-------+------------+
|   1 |   100 | wang       |
|   2 |  1000 | zhang      |
|   3 |  2000 | li         |
|   4 |  5000 | weizhi     |
|   5 |  5000 | cai        |
+-----+-------+------------+
5 rows in set (0.00 sec)

插入部分字段

mysql> insert into pw_price(uid,first_name) values (6,'guo');
Query OK, 1 row affected (0.03 sec)

mysql> select * from pw_price;\
+-----+-------+------------+
| uid | price | first_name |
+-----+-------+------------+
|   1 |   100 | wang       |
|   2 |  1000 | zhang      |
|   3 |  2000 | li         |
|   4 |  5000 | weizhi     |
|   5 |  5000 | cai        |
|   6 |  NULL | guo        |
+-----+-------+------------+
6 rows in set (0.00 sec)

插入检索数据

mysql>  insert into pw_price(uid,first_name) select uid,first_name from pw_price;

 

posted on 2015-02-28 11:25  wjw334  阅读(129)  评论(0编辑  收藏  举报

导航