一、基本操作
1、创建数据库
链接数据库
mysql -uroot -p+(密码)
退出
quit/exit
创建
create database AB_name charset=utf8;
2、选择数据库
进入数据库 use AB_name ;
查看当前所选的数据库: select database();
3、创建表
创建一个顾客表
create table customer(id int primary key auto_increment not null,
name varchar(10) not null,
password varchar(10) not null,
gender enum('boy','girl','secret'),
active int default 0);
4、查看数据库里的表
show tables;
5、查看表的结构
desc customer(表名)
6、删库操作
drop database AB_name;
7、增加字段
alter table customer add email varchar(20) not null;
8、修改字段
alter table customer change name user_name varchar(20) not null;
9、删除字段
alter table customer drop email;
10、删除表
drop table customer