DATABASE 数据库
语法
-- 创建 数据库的 CREATE 权限
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[create_option] ...
create_option: [DEFAULT] {
CHARACTER SET [=] charset_name
| COLLATE [=] collation_name
}
-- 删除 数据库具有 DROP 权限
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
查看数据库创建语句
mysql> show create database world;
+----------+---------------------------------------------------------------------------------+
| Database | Create Database |
+----------+---------------------------------------------------------------------------------+
| world | CREATE DATABASE `world` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ |
+----------+---------------------------------------------------------------------------------+
1 row in set (0.06 sec)
mysql>
创建数据库
## 创建数据库
mysql> create database test;
Query OK, 1 row affected (0.01 sec)
## 查看数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| dbsnmp |
| mysql |
| performance_schema |
| sakila |
| sys |
| test |
| world |
+--------------------+
8 rows in set (0.00 sec)
切换数据库
## 切换数据库
mysql> use world;
Database changed
查看数据库中存在的表
## 显示数据库中的表
mysql> show tables;
+-----------------+
| Tables_in_world |
+-----------------+
| city |
| city_view |
| country |
| countrylanguage |
+-----------------+
4 rows in set (0.03 sec)
mysql>