1.创建表
mysql> create table employee(
-> id int(10) not null primary key);
mysql> alter table employee add name varchar(10);
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table employee add gender enum(‘男’,‘女’);
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table employee add salary int;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
2.添加数据
mysql> insert into employee values(1,‘张三’,‘男’,2000);
Query OK, 1 row affected (0.00 sec)
mysql> insert into employee values(2,‘李四’,‘男’,1000);
Query OK, 1 row affected (0.00 sec)
mysql> insert into employee values(3,‘王五’,‘女’,4000);
Query OK, 1 row affected (0.01 sec)
3.1
mysql> update employee set salary=‘5000’;
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
3.2
mysql> update employee set salary=‘3000’ where name=‘张三’;
3.3
mysql> update employee set salary=‘4000’ , gender=‘女’ where name=‘李四’;
3.4
mysql> update employee set salary=salary+1000 where name=‘王五’;