I_am_feminist Asked: 2017-04-28 20:53:31 +0800 CST2017-04-28 20:53:31 +0800 CST 2017-04-28 20:53:31 +0800 CST 如何将值插入到添加到现有表中的新列中? 772 如果您知道如何将值插入到添加到现有表中的新列中,请回答我。您的回答将不胜感激 mysql 1 个回答 Voted Best Answer atokpas 2017-04-28T20:57:12+08:002017-04-28T20:57:12+08:00 您需要更新现有表。 mysql> create table tbl1(id int); Query OK, 0 rows affected (0.04 sec) mysql> insert into tbl1 values(1); Query OK, 1 row affected (0.00 sec) mysql> insert into tbl1 values(2); Query OK, 1 row affected (0.00 sec) mysql> alter table tbl1 add column name varchar(20); Query OK, 0 rows affected (0.13 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> select * from tbl1; +------+------+ | id | name | +------+------+ | 1 | NULL | | 2 | NULL | +------+------+ 2 rows in set (0.00 sec) mysql> update tbl1 set name='Jay' where id=1; Query OK, 1 row affected (0.09 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from tbl1; +------+------+ | id | name | +------+------+ | 1 | Jay | | 2 | NULL | +------+------+ 2 rows in set (0.00 sec) mysql> update tbl1 set name='Joe' where id=2; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from tbl1; +------+------+ | id | name | +------+------+ | 1 | Jay | | 2 | Joe | +------+------+ 2 rows in set (0.00 sec)
您需要更新现有表。