MySQL中的表中增加删除字段
1增加两个字段:
mysql> create table id_name(id int,name varchar(20)); Query OK, 0 rows affected (0.13 sec) mysql> alter table id_name add age int,add address varchar(11); Query OK, 0 rows affected (0.13 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> desc id_name; +---------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | name | varchar(20) | YES | | NULL | | | age | int(11) | YES | | NULL | | | address | varchar(11) | YES | | NULL | | +---------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec) 2.删除两个字段 mysql> alter table id_name drop column age,drop column address; Query OK, 0 rows affected (0.14 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> desc id_name; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | name | varchar(20) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) 3.插入 mysql> insert into id_name values (1,‘qustdjx‘); Query OK, 1 row affected (0.00 sec) 4.查询看一下 mysql> alter table id_name add age int,add address varchar(11); Query OK, 1 row affected (0.07 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from id_name; +------+---------+------+---------+ | id | name | age | address | +------+---------+------+---------+ | 1 | qustdjx | NULL | NULL | +------+---------+------+---------+ 1 row in set (0.00 sec) 5.新增字段并插入 mysql> insert into id_name values(2,‘qust‘,14,‘山东‘); Query OK, 1 row affected (0.00 sec) mysql> select * from id_name; +------+---------+------+---------+ | id
相关推荐
Dullonjiang 2020-07-30
sofast 2020-07-08
AngelicaA 2020-07-04
Iamready 2020-06-25
TMD咯MySQL 2020-06-16
窃破天道 2020-06-12
tanyhuan 2020-06-09
debugjoker 2020-06-07
nan00zzu 2020-06-07
BiPerler 2020-06-03
勇往直前 2020-06-01
huangyx 2020-05-29
阿亮 2020-05-28
Justagreenonion 2020-05-14
sunnyJam 2020-04-03
数据库之扑朔迷离 2020-04-26
gamestart0 2020-04-10
李轮清 2020-05-11
imacoder 2020-05-10