前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >数据定义语句(2)DROP DATABASE

数据定义语句(2)DROP DATABASE

作者头像
渔父歌
发布2019-11-13 19:47:49
5600
发布2019-11-13 19:47:49
举报
文章被收录于专栏:数据结构笔记数据结构笔记

删除数据库。语法规则如下:

代码语言:javascript
复制
DROP {DATABASE|SCHEMA} [IF EXISTS] db_name

执行 DROP DATABASE 会删除数据库里的所有表然后再删除数据库,所以执行这条语句的时候一定要慎重。要执行该语句,你需要拥有数据库的 DROP 权限。DROP SCHEMADROP DATABASE 可以互相替换。

特别注意: 当在删除数据库时,与数据库相关的授权信息不会被自动删除,这些信息必须手动删除。

当数据库不存在时,使用 IF EXISTS 来避免产生错误。

DROP DATABASE 的返回值删除的表的数量。

当删除内置的数据库时,只将数据库清空恢复到初始状态,不会真正执行删除操作。

注:引用部分大意是删除数据库时会删除哪些文件,这些与其他内容有关联,留到后面一起翻译。

If you use DROP DATABASE on a symbolically linked database, both the link and the original database are deleted. DROP DATABASE returns the number of tables that were removed. This corresponds to the number of .frm files removed. The DROP DATABASE statement removes from the given database directory those files and directories that MySQL itself may create during normal operation: • All files with the following extensions: • .BAK • .DAT • .HSH • .MRG • .MYD • .MYI • .TRG • .TRN • .cfg • .db • .frm • .ibd • .ndb • .par • The db.opt file, if it exists. If other files or directories remain in the database directory after MySQL removes those just listed, the database directory cannot be removed. In this case, you must remove any remaining files or directories manually and issue the DROP DATABASE statement again. Dropping a database does not remove any TEMPORARY tables that were created in that database. TEMPORARY tables are automatically removed when the session that created them ends. See Section 13.1.18.3, “CREATE TEMPORARY TABLE Syntax”. You can also drop databases with mysqladmin. See Section 4.5.2, “mysqladmin — Client for Administering a MySQL Server”.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档