- 命令说明
{} ---必选项
| ---分隔选择项
[] ---可选项
- 创建DB
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name [DEFAULT] CHARACTER SET [=] charset_name
[IF NOT EXISTS] ---忽略产生的错误信息 CHARACTER SET [=] charset_name ---设置DB编码方式CREATE DATABASE t1;CREATE DATABASE t2 CHARACTER SET = gbk; Query OK ---与查找不同 1 row affected ---创建t1数据库的结果放入系统数据库中
- 查看DB
SHOW {DATABASES | SCHEMA} [LIKE 'pattern' | WHERE expr]
SHOW DATABASES; SHOW CREATE DATABASE t1; ---显示DB创建时的指令 SHOW WARNINGS; ---查看警告信息- 修改DB
ALTER {DATABASE | SCHEMA} [db_name] [DEFAULT] CHARACTER SET [=] charset_name
ALTER DATABASE t2 CHARACTER SET = utf8; SHOW CREATE DATABASE t2;- 删除DB
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
DROP DATABASE t2;
- 其他:
MySQL安装后默认带4个DB