SQL语法基础之DROP语句
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.查看DROP帮助信息
mysql> ? DROP Many help items for your request exist. To make a more specific request, please type 'help <item>', where <item> is one of the following topics: ALTER TABLE DEALLOCATE PREPARE DROP DATABASE DROP EVENT DROP FUNCTION DROP FUNCTION UDF DROP INDEX DROP PROCEDURE DROP RESOURCE GROUP DROP ROLE DROP SERVER DROP SPATIAL REFERENCE SYSTEM DROP TABLE DROP TABLESPACE DROP TRIGGER DROP USER DROP VIEW mysql> mysql>
二.DROP DATABASE
DROP DATABASE语句用来删除数据库操作,即删除了数据库也删除数据库里的所有表。
1>.查看DROP DATABASE的帮助信息
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
mysql> ? DROP DATABASE Name: 'DROP DATABASE' Description: Syntax: DROP { DATABASE | SCHEMA} [IF EXISTS] db_name DROP DATABASE drops all tables in the database and deletes the database. Be very careful with this statement! To use DROP DATABASE, you need the DROP privilege on the database. DROP SCHEMA is a synonym for DROP DATABASE. *Important*: When a database is dropped, privileges granted specifically for the database are not automatically dropped. They must be dropped manually. See [HELP GRANT]. IF EXISTS is used to prevent an error from occurring if the database does not exist. URL: http://dev.mysql.com/doc/refman/8.0/en/drop-database.html mysql>
2>.删除数据库的操作将删除改数据库所在文件夹乳腺癌格式的文件,以及db.opt文件
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | A1 | | A2 | | A3 | | course | | day03 | | devops | | information_schema | | mysql | | performance_schema | | sys | | yinzhengjie | +--------------------+ 11 rows in set (0.00 sec) mysql> mysql> DROP DATABASE A1; #删除一个已经存在的库,由于我知道该库肯定存在,因此这里我就没有使用判断语句! Query OK, 1 row affected (0.00 sec) mysql> mysql> DROP DATABASE IF EXIST