Day_01MySQL常用操作命令

1.创建操作日志
\T C:\ProgramData\MySQL\MySQL Server 8.0\MySQL命令符操作保存日志-自建文件夹\MySQL-Log.txt
2.创建数据库
CREATE (DATABASE | SCHEMA ) IF NOT EXISTS 数据库名称 CHARACTER SET;
默认 ; or \g 作为命令结束
例:CREATE DATABASE test1; 或者 CREATE SCHEMA IF NOT EXISTS test1;
IF NOT EXISTS :检查是否存在,如果不存在创建,如果存在提示警告,但是不是显示错误。
例:mysql>CREATE SCHEMA IF NOT EXISTS test1; Query OK, 1 row affected, 1 warning (0.00 sec)
CHARACTER SET:编码格式
3.查看这个警告
SHOW WARNINGS;
4.查看所有数据库
SHOW DATABASES; 或者 SHOW SCHEMAS;
5.查看数据库的创建
SHOW CREATE DATABASE test1;
结果:+----------+---------------------------------------------------------------------------------------------------------------------------------+ | Database | Create Database | +----------+---------------------------------------------------------------------------------------------------------------------------------+ | test1 | CREATE DATABASEtest1/*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ | +----------+---------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
6.更改编码格式
ALTER DATABASE test1 DEFAULT CHARACTER SET GBK;
7.打开数据库或者切换数据库
USE test1;
8.查看当前数据库
SELECT DATABASE();
9.删除数据库,IF EXISTS:如果存在,不报错误,只提示警告
DROP DATABASE IF EXISTS test1;
例:mysql>DROP DATABASE IF EXISTS test1;
Query OK, 0 rows affected (0.01 sec)

mysql>DROP DATABASE IF EXISTS test1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>SHOW WARNINGS;
Empty set (0.00 sec)

10.帮助文档,help

mysql>help tinyint
Name: 'TINYINT'
Description:
TINYINT[(M)] [UNSIGNED] [ZEROFILL]

A very small integer. The signed range is -128 to 127. The unsigned
range is 0 to 255.

URL: https://dev.mysql.com/doc/refman/8.0/en/numeric-type-overview.html

你可能感兴趣的:(Day_01MySQL常用操作命令)