數據定義語句(2)DROP DATABASE

刪除數據庫。語法規則如下:

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”.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章