mysql数据库简单练习(创建表格,增删改查数据)
1.创建一个员工表
字段 属性
id 整形(int)
name 字符串(varchar)(长度为20)
gender 字符串(长度为2)
birthday 日期型(date)
email 字符串(长度为10)
remark 字符串(长度为50)
use lianxi; 进数据库 create table yuangong( 建表 id int,name varchar(20), gender char(2), birthday date, email char(10), remark char(50))
2.修改表练习
2.1 在员工表基础上增加age列
2.2 修改email列长度为50
2.3 删除remark列
2.4 列名name修改为username
ALTER TABLE yuangong ADD COLUMN age INT; ALTER TABLE yuangong MODIFY COLUMN email CHAR(50); ALTER TABLE yuangong DROP COLUMN remark; ALTER TABLE yuangong CHANGE COLUMN NAME username VARCHAR(20); INSERT INTO yuangong(id,username,gender)VALUES(1,'小明','男'); INSERT INTO yuangong(birthday)VALUES('2015-10-2 00:00:00'); INSERT INTO yuangong VALUES( 1, '小驴', '女', '2015-10-3 00:00:00', '111',15); UPDATE yuangong SET age = 20 WHERE age = 15; UPDATE yuangong SET age = 30 WHERE age = 15; DELETE FROM yuangong WHERE age = 20;