启动MySQL net start mysql
停止MySQL net stop mysql
进入MySQL安装目录 c:\wamp\bin\mysql\mysql5.6.17\bin\
进入MySQL mysql.exe -h localhost -u root -p
退出MySQL exit;
查看已创建的数据库 show databases;
创建数据库 create database fly_test character set gbk;
指定使用的数据库 use fly_test;
创建表 create table students(id int not null auto_increment,name varchar(12),age int,sex varchar(4),primary key (id) );
查看表 show tables;
查看表的详细信息 describe students;
插入数据 insert into students values( "白鸽", "男", 20, "18888888888" );
insert into students(name, sex, age)values("龙颜", "男", 10);
查询 select name, age from students;
select * from students;
条件查询 select * from students where age > 12;
select * from students where name like "%白";
select * from students where id < 5 and age > 2;
排序 select * from students order by age [desc];
更新 update students set tel = default where id = 1;
update students set age = age + 1;
update students set name = "baige", sex = "nan" where age = 21;
删除 delete from students where id =3;
删空表 delete from students;
添加列 alter table students add address char(60);
alter table students add birthday date after age;
alter table students change tel telphone char(13) default "-";
alter table students change name name char(16) not null;
删除列 alter table students drop birthday;
重命名表 alter table students rename workmates;
删除整张表 drop table 表名;
删除数据库 drop database 数据库名;