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';

 

posted @   小丑鱼儿  阅读(33)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!
点击右上角即可分享
微信分享提示