1.数据库操作
·创建数据库
mysql> create database new_db2;
Query OK, 1 row affected (0.01 sec)
·删除数据库
mysql> drop database new_db2;
Query OK, 0 rows affected (0.01 sec)
·查询创建数据库
mysql> show create database new_db2;
+----------+-----------------------------------------------------------------------------------------------------------------------------------+
| Database | Create Database |
+----------+-----------------------------------------------------------------------------------------------------------------------------------+
| new_db2 | CREATE DATABASE `new_db2` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ |
+----------+-----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
·使用数据库
mysql> use new_db2;
Database changed
·查询当前默认的数据库
mysql> select database();
+------------+
| database() |
+------------+
| new_db2 |
+------------+
1 row in set (0.00 sec)
·查询使用的编码方式
mysql> select @@character_set_database, @@collation_database;
+--------------------------+----------------------+
| @@character_set_database | @@collation_database |
+--------------------------+----------------------+
| utf8mb4 | utf8mb4_0900_ai_ci |
+--------------------------+----------------------+
1 row in set (0.00 sec)
2.表的创建
mysql> create table mulit_tb(
-> `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',
-> `describtion1` blob comment '描述1',
-> `describtion2` mediumblob comment '描述2',
-> `describtion3` longblob comment '描述3',
-> `age` tinyint comment '年龄',
-> `salary` smallint comment '工资',
-> `salary2` int comment '资产',
-> `salary3` mediumint comment '大资产',
-> `code` bigint comment '代码量'
-> )engine = InnoDB default character set utf8;
Query OK, 0 rows affected, 1 warning (0.01 sec)