当前位置:网站首页>mysql非常用命令
mysql非常用命令
2022-04-22 05:32:00 【有梦想的攻城狮】
简单描述表结构和字段
desc table_name
查询表中列的注释信息
//查询表中字段信息和注释信息
select * from information_schema.columns where table_schema = "db_name"(库名) and table_name = "table_name" (表名);
//只查询字段名和字段注释信息
select column_name, column_comment from information_schema.columns where table_schema = "db_name" and table_name = "table_name";
查看生产表的DDL
show create table #{table_name};
复制表结构
create table table_name_copy like table_name;
复制表数据
insert into #{table_name_copy} select * from #{table_name};
修改字段类型
alter table #{table_name} modify column #{column_name} #{column_type}
例如:修改user表中的address字段从char(30) 修改为 varchar(60)
alter table user modify column address varchar(60)
修改字段长度
alter table #{table_name} modify column #{column_name} #{column_type}
例如:修改user表中的address字段从varchar(60)修改为varchar(100)
alter table user modify column address varchar(100);
批量生产删表语句
select concat('drop table ', table_name, ';') from information_schema.tables where table_schema='database_name';
查询表中所有字段
select GROUP_CONCAT(COLUMN_NAME) from information_schema.COLUMNS where table_name = '表名' and table_schema ="数据库名";
查询是否锁表
show OPEN TABLES where In_use > 0;
查看全部进程
show processlist
杀死进程ID
kill id
查看当前事务
SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;
查看当前锁定的事务
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;
查看当前等锁的事务
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
通过命令行登录并指定数据库
mysql -h ${数据库IP} -P 3306 -u ${用户名} -p -D ${数据库名}
为数据库添加管理员
grant all privileges on ${数据库名}.* to '${数据库管理员}'@'%' identified by '${用户密码}' with grant option;
#刷新数据库
flush privileges;
版权声明
本文为[有梦想的攻城狮]所创,转载请带上原文链接,感谢
https://zhangzehai.blog.csdn.net/article/details/111500373
边栏推荐
- ENUM et expressions lambda
- [candelastudio edit CDD] - 2.3 - realize the jump between multiple securitylevels of $27 service (UDS diagnosis)
- Sword finger offer | merge two sorted linked lists
- Application of C language stack: binary conversion
- Enumerations and lambda expressions
- GBase 8s V8. 8 SQL Guide: tutorial-5.3
- 深圳-西双版纳
- Unable to resolve dependency for ': app@debug /compileClasspath': Could not download mapsforge-map. jar
- C language version: the pre order, middle order and post order non recursive traversal of binary tree
- C language version: dynamic establishment of binary tree
猜你喜欢

Domain based approach - score prediction

Pratique du langage C (2) - - mise en oeuvre de l'addition polynomiale par liste liée

Cookie injection

使用easyexcel导出excel表格

unity接入ILRuntime之后 热更工程应用Packages下面的包方法 例如Unity.RenderPipelines.Core.Runtime包

C WinForm about incomplete display of listview

Auto.js 画布设置防锯齿paint.setAntiAlias(true);

MySQL Chapter 6 installation and use of Navicat

Unable to resolve dependency for ': app@debug /compileClasspath': Could not download mapsforge-map. jar

深圳-西双版纳
随机推荐
Temporary data node usage based on unitygameframework framework
After unity is connected to the ilruntime, the package method under packages is applied to the hot engineering application, such as unity RenderPipelines. Core. Runtime package
Unity is limited to execute every few frames in update
MySQL函数及练习题(二)
GBase 8s V8.8 SQL 指南:教程-6.1.1(2)
Enumerations and lambda expressions
MySQL 第6章 Navicat 的安装与使用
GBase 8s V8.8 SQL 指南:教程-6.1.1(4)
C WinForm about incomplete display of listview
Implementation of unity simple event system
New tips for JS in 2022
MySQL transaction
Shenzhen Xishuangbanna
【FedMD,一种利用模型蒸馏的异构FL训练方法】FedMD: Heterogenous Federated Learning via Model Distillation
C language version: the establishment and basic operation of chain stack
Using easyexcel to export excel forms
Kaggle_ Detailed explanation of NBME NLP competition baseline (2)
Method for coexistence of Keil-C51 and keil arm
MySQL installation and configuration - detailed tutorial
MySQL JDBC 编程