一:库管理:
1.查看:
1)查看库:show databases;
2)查看当前库:select database();
3)查看某个库建库语句:show create database 库名;
2.创建:
1)语法:create database 库名 [字符集]
库名命名规则:
可以使用数字、字母、下划线,不能使用纯数字;
区分大小写,不能使用特殊字符和关键字
库名必须唯一
2)e.g.
create database eshop default charset=utf8;
3.进入/切换库:use 库名;
4.[如果存在]删除库:
drop database [if exists] 库名;
二:表管理:
1.查看:
1)查看库中有哪些表:show tables;
2)查看指定表的表结构:desc 表名;
3)查看建表语句:show create table 表名;
2.创建:
1)建表之前先入库
2)语法:
create table 表名称(
列名称1 列类型1(长度) [约束1],
...
)[字符集];
3.删除:drop table [if exists] 表名;