对库的操作

创建数据库:#create database 数据库名 (字符集设置 default character set uft8);

 

mysql> create database test_1 default character set utf8;
Query OK, 1 row affected (0.00 sec)

 

删除数据库:#drop database 数据库名;

mysql> drop database test_1;
Query OK, 0 rows affected (0.00 sec)

查看数据库:#show databases; 可以查看当前有几个数据库;分别叫什么;

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test_1             |
+--------------------+
5 rows in set (0.00 sec)

查看某一数据库的详细信息(字符集):#show create database 数据库名;

mysql> show create database test_1;
+----------+-----------------------------------------------------------------+
| Database | Create Database                                                 |
+----------+-----------------------------------------------------------------+
| test_1   | CREATE DATABASE `test_1` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-----------------------------------------------------------------+
1 row in set (0.00 sec)

 

对表的操作

操作表之前必须知道你要操作哪一个库的表,然后进入这个库

切换某一个库:#use 库名;

 

mysql> use test_1;
Database changed

 

查看某一个表