登录:mysql -u root -p
创建数据库:create database if not exists students
default charset utf8 collate utf8_general_ci;
使用数据库:use 数据库名称
创建数据表及字段名: create table if not exists 数据库名字
(
id
int unsigned auto_increment,
-> name
varchar(50) not null,
-> age
int(25) not null,
-> gender
varchar(50) not null,
-> score
int(25) not null,
-> primary key ( id
)
-> )engine=InnoDB default charset=utf8; %注意(分号结尾是运行)
输入数据:insert into 表名(字段名)values(字段值)
列入上面:insert into stuinfo(name,sex,score,age)valuse(“”,“”,“”,“”),
%注意(,结尾是以下也有关系)
查看数据表:select * from stuinfo;
查询所有男生的数据只需要学生的姓名和年龄):select name,age from stuinfo sex="";
查询及格学生成绩信息(学生成绩大于或等于60):select * from stuinfo where score>=“60”;
按照学生的分数进行排序:select * from stuinfo order by score;
所有女生的年龄增加一岁:update stuinfo set age=age+1 where sex=""
%注意“里面的数据自己设” 字段名注意自己所设
标题