1,创建数据库
mysql> create database gbk_db default character set gbk collate gbk_chinese_ci;
Query OK, 1 row affected (0.01 sec)
2,删除数据库
mysql> drop database gbk_db;
Query OK, 0 rows affected (0.02 sec)
3,查询创建数据
mysql> show create database gbk_db;
+----------+---------------------------------------------------------------------------------------------------+
| Database | Create Database |
+----------+---------------------------------------------------------------------------------------------------+
| gbk_db | CREATE DATABASE `gbk_db` /*!40100 DEFAULT CHARACTER SET gbk */ /*!80016
DEFAULT ENCRYPTION='N' */ |
+----------+---------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
4,使用数据库
mysql> use gbk_db;
Database changed
5,查询当前默认的数据库
mysql> select database();
+------------+
| database() |
+------------+
| gbk_db |
+------------+
1 row in set (0.00 sec)
6,查询当前数据库使用的编码方式校验规则
mysql> select @@character_set_database, @@collation_database;
+--------------------------+----------------------+
| @@character_set_database | @@collation_database |
+--------------------------+----------------------+
| gbk | gbk_chinese_ci |
+--------------------------+----------------------+
1 row in set (0.00 sec)
创建表中使用的所有的数据类型
mysql> create table multi_tb(
-> id int(11) comment '编号',
-> company_name char(6) comment '公司名称',
-> introduce varchar(100) comment '介绍',
-> content1 tinytext comment '内容1',
-> content2 text comment '内容2',
-> content3 mediumtext comment '内容3',
-> content4 longtext comment '内容4',
-> description1 blob comment '描述1',
-> description2 mediumblob comment '描述2',
-> description3 longblob comment '描述3',
-> iq tinyint comment '0705数据库IQ',
-> salary smallint comment '薪资',
-> five_plan mediumint comment '五年计划',
-> description1 blob comment '描述1',
-> description2 mediumblob comment '描述2',
-> description3 longblob comment '描述3',
-> iq tinyint comment '0705数据库IQ',
-> salary smallint comment '薪资',
-> five_plan mediumint comment '五年计划',
-> code_num bigint comment '代码量',
-> Establishedtime date comment '公司成立时间',
-> markettime datetime comment '公司上市时间',
-> birthday timestamp comment '老总生日',
-> Deadline time comment '五年计划截至时间',
-> establishment year comment '成立年份',
-> )engine=InnoDB default character set utf8mb4 collate utf8mb4_0900_ai_ci;
Query OK, 0 rows affected, 1 warning (0.02 sec)