mysql 操作sql语句 操作数据库

时间:2021-09-13 06:42:59

sql语句

#1. 操作文件夹
创建数据库:create database db1 charset utf8;
查数据库:show databases;
mysql> create database db1 charset utf8;
Query OK, 1 row affected (1.50 sec) mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db1 |
| mysql |
| test |
+--------------------+
4 rows in set (0.01 sec)

查看刚才创建的数据库信息   字符编码


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

  改字符编码 改哪个数据库
改:alter database db1 charset gbk;
mysql> show create database db1 ;
+----------+-------------------------------------------------------------+
| Database | Create Database |
+----------+-------------------------------------------------------------+
| db1 | CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET gbk */ |
+----------+-------------------------------------------------------------+
1 row in set (0.00 sec)


    
删除数据库: drop database db1;