MySql常用命令
-- show命令介绍
show databases; 查看数据库名
show tables; 查看表名
show create database xx ; 查看创建数据库语句
show create table; 查看创建表语句
show processlist; 查看所有用户连接状态
show charset; 查看支持的字符集
show collation; 查看所支持的校对规则
show grants for root; 查看用户的权限
show variables like '%char%'; 查看参数信息
show engines; 查看所有支持的存储引擎类型
show index from stu; 查看表的索引信息
show engine innodb status\G; 查看innoDB详细状态信息
show binary logs; 查看当前使用的二进制日志信息
show status like ' ' 查看数据库整体状态信息
-- 创建相同表命令
create table test like stu;
-- 给表增加列
alart table stu add qq varchar(20) NOT NULL COMMENT 'q';
-- 删除表列
alter table stu drop qq;
-- 创建视图和使用视图查询
create view student1990 as select stuId,name from student where year(birthday)=1990;
select * from student1990;
-- 通过information_schema查看数据库所有表
select * from information_schema.tables;
-- 数据库大小统计
select table_schema,SUM((AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH))/1024
from information_schema.`TABLES`
where table_schema='hello'
-- 使用CONCAT进行拼接语句
-- 数据库分库分表备份
mysqldump -uroot -p hello stu >/home/demo/hello_stu.sql
SELECT
CONCAT("mysqldump -uroot -p123456 ",table_schema," ",table_name,">/home/demo/",table_schema,"_",table_name,".sql")
FROM information_schema.tables
WHERE table_schema='hello';
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!