作业:
1.创建表:
创建员工表employee,字段如下:
id(员工编号),name(员工名字),gender(员工性别),salary(员工薪资)
2.插入数据
1,‘张三’,‘男’,2000
2,‘李四’,‘男’,1000
3,‘王五’,‘女’,4000
3.修改表数据
3.1将所有员工薪水修改为5000元
3.2将姓名为张三的员工薪水修改为3000元
3.3将姓名为李四的员工薪水修改为4000元,gener改为女
3.4 将王五的薪水在原有基础上增加1000元
mysql> create table employee(
-> id int primary key,
-> name varchar(20) not null,
-> gender char(2) default '男',
-> salary int
-> );
mysql> desc employee;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| name | varchar(20) | NO | | NULL | |
| gender | char(2) | YES | | 男 | |
| salary | int(11) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
mysql> insert into employee values(1,'张三','男',2000),(2,'李四','男',1000),(3,'王五','女',4000);
mysql> select * from employee;
+----+--------+--------+--------+
| id | name | gender | salary |
+----+--------+--------+--------+
| 1 | 张三 | 男 | 2000 |
| 2 | 李四 | 男 | 1000 |
| 3 | 王五 | 女 | 4000 |
+----+--------+--------+--------+
mysql> update employee set salary=5000;
mysql> select * from employee;
+----+--------+--------+--------+
| id | name | gender | salary |
+----+--------+--------+--------+
| 1 | 张三 | 男 | 5000 |
| 2 | 李四 | 男 | 5000 |
| 3 | 王五 | 女 | 5000 |
+----+--------+--------+--------+
mysql> update employee set salary=3000 where name='张三';
mysql> select * from employee;
+----+--------+--------+--------+
| id | name | gender | salary |
+----+--------+--------+--------+
| 1 | 张三 | 男 | 3000 |
| 2 | 李四 | 男 | 5000 |
| 3 | 王五 | 女 | 5000 |
+----+--------+--------+--------+
mysql> update employee set salary=3000,gender='女' where name='李四';
mysql> select * from employee;
+----+--------+--------+--------+
| id | name | gender | salary |
+----+--------+--------+--------+
| 1 | 张三 | 男 | 3000 |
| 2 | 李四 | 女 | 3000 |
| 3 | 王五 | 女 | 5000 |
+----+--------+--------+--------+
mysql> update employee set salary=salary+1000 where name='王五';
mysql> select * from employee;
+----+--------+--------+--------+
| id | name | gender | salary |
+----+--------+--------+--------+
| 1 | 张三 | 男 | 3000 |
| 2 | 李四 | 女 | 3000 |
| 3 | 王五 | 女 | 6000 |
+----+--------+--------+--------+
有帮助烦请点赞支持一下,谢谢。
文章有问题请品论或联系更正: [email protected]