库操作,DDL
创建,create
---------
(create,几乎所有的结构都是用该语法完成)
create database 库名 [库选项]

注意的问题:
库选项,只有字符集,校对集的概念!
每个库,会对应一个数据目录
存放在当前mysql的总的数据库目录内
参考 mysql的配置文件得到该目录:


看到刚刚的数据库目录:

看看目录内,没有表,没有其他文件,除了一个数据库选项文件:


数据库名的问题
大小写问题,取决于mysql服务器,所在的操作系统!(建议是,认为区分)
特殊名称,关键字,特殊字符等!默认是不可以的!

但是,可以使用反引号将名称包裹起来,告知服务器,此处一个名字,而不是特殊操作!

中文等都可以作为标识符(库名),需要同样反引号!(多字节字符,还需要注意字符集的问题)

===================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
查询(看看有哪些库,库的基本结构),show
----------------------
### 查询已有的数据库名字
show databases;

show databases likes;
like 关键字用于过滤多个数据库!

可以使用通配符(通用匹配符,可以匹配多个字符)
% 匹配任意字符的任意次数(包括0次)的组合!
\_ 匹配任意字符的一次!
like ‘x\_y’;
x1y xby xxy(可以)
xy(不可以)
通配符是与 like 关键字一起使用!
注意如需要匹配特定的通配符,则需要对通配符转义,使用反斜杠\\完成转义!

==================================================================================================================================================================================================================================================================================================================================================================================================================================================================
### 查看某个数据库的定义
show create database 库名;


==========================================================================================================================================================
修改,alter
--------
alter database 数据库名
只能修改数据库选项

=============================================================================================================
删除,drop
-------
drop database 名字

=============================================================================================
if not exists, if exists
------------------------
在 create 与 drop 时,创建和删除时,有两个额外的操作:
create database if not exists 库名
如果不存在则创建
drop database if exists 库名
如果存在,则删除

==================================================================================================================================================================================================================================
删除库
---
增加删除的链接,传递所操作的库名!
在数据库列表页:


增加一个处理删除的功能页面:
在形成 sql时,只要出现了标识符(库名,表名,字段名,索引名),都使用反引号!
请求跳转:
header(‘Location: url’);//告知浏览器,对新的url发出请求!
database\_drop.php

========================================================================================================================================================================================================================================================================================================================================================================================
新建库
---
执行 create database
列表页,增加一个链接,请求到创建页:

增加一个create\_form表单页面

在增加一个脚本处理该数据即可
database\_create.php

如果存在多个选项,因该如何处理?
例如字符集!
应该,取得所有的字符集。
利用 show character set;可以展示所有的字符集!


在创建库时,需要先对哪个字符集做一次判断!(是否是默认)
database\_create.php

=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================