网站首页 > 技术文章 正文
show global variables like 'port';
查看mysql使用的端口是多少
库:
- show databases;
显现所有数据库
- create database [if not exists] 数据库名;
创建数据库
- drop database [if exists] 数据库名;
删除数据库
- show create database 数据库名;
显示创建数据库语句
- select database();
查看当前是连接哪个数据库
- use 数据库名;
使用数据库
表:
- show tables;
查询当前数据库中的全部表
- show create table 表名;
显示创建表的语句
- describe/desc 表名;
查看表结构
- drop table [if not exists] 表名;
删除表
- alter table 原表名 rename to 新表名;
修改表名
- alter table 表名 add 字段名 字段类型;
添加字段
- alter table 表名 change 原始字段名 新的字段名 新数据类型 [默认值] [注释];
修改字段名、字段数据类型、【默认值】、【注释】
例:alter table table01 change id id01 int default 10 comment '序号';
--将table01表中的字段id改名为id01,数据类型为int,默认值为10,注释为“序号”
- alter table 表名 modeify [column] 字段名 字段类型 [默认值] [注释];
修改字段的数据类型、【默认值】、【注释】
- alter table 表名 drop [column] 字段名
删除字段
扩展:
注释:
- select table_name 表名,table_comment 表注释,table_schema
from information_schema.tables
where table_schema = ‘数据库名’
order by table_name;
查看数据库中的所有表注释
- select table_name 表名,table_comment 表注释,table_rows 数据量
from information_schema.tables
where table_schema = '数据库名’
order by table_name;
查看数据库下的所有表的表名、表注释及其数据量
- select column_name 字段名,column_comment 字段注释
from information_schema.columns
where table_name=’表名’ and table_schema='数据库名';
查看数据库下的表的表字段注释
- select a.table_name 表名,a.table_comment 表注释,b.column_name
表字段,b.column_type 字段类型,b.column_comment 字段注释
from information_schema.tables a,information_schema.columns b
where b.table_name=a.table_name and a.table_schema='数据库名’;
查看数据库下的所有表的表名、表注释以及对应表字段注释
- alter table 表名 comment '注释内容';
修改表注释
- alter table 表名 modify column 字段名 字段类型 comment '注释内容';
修改表的表字段注释
注意:字段名和字段类型照写就行,如果之前有规定长度 这里也要指定一下
- 上一篇: C/C++编程笔记:C++基础部分丨默认参数,你了解吗?
- 下一篇: Java 基础面试知识点
猜你喜欢
- 2025-05-27 Python进阶 - day1:深入理解数据结构
- 2025-05-27 Java中transient字段的作用
- 2025-05-27 深度学习数据集处理常用函数示例(Python)
- 2025-05-27 Go语言-指针
- 2025-05-27 什么是 happens-before 规则?
- 2025-05-27 「Java」一张图教会你关于null的几种处理方式(内附代码)
- 2025-05-27 Python 中常用的数据结构,帮助你从基础到精通
- 2025-05-27 1、数值类型
- 2025-05-27 基础函数20例,案例解读,再不掌握就真的Out了
- 2025-05-27 12 个 C# 提效实用干货
- 08-06中等生如何学好初二数学函数篇
- 08-06C#构造函数
- 08-06初中数学:一次函数学习要点和方法
- 08-06仓颉编程语言基础-数据类型—结构类型
- 08-06C++实现委托机制
- 08-06初中VS高中三角函数:从"固定镜头"到"360°全景",数学视野升级
- 08-06一文讲透PLC中Static和Temp变量的区别
- 08-06类三剑客:一招修改所有对象!类方法与静态方法的核心区别!
- 1524℃桌面软件开发新体验!用 Blazor Hybrid 打造简洁高效的视频处理工具
- 662℃Dify工具使用全场景:dify-sandbox沙盒的原理(源码篇·第2期)
- 528℃MySQL service启动脚本浅析(r12笔记第59天)
- 494℃启用MySQL查询缓存(mysql8.0查询缓存)
- 493℃服务器异常重启,导致mysql启动失败,问题解决过程记录
- 481℃「赵强老师」MySQL的闪回(赵强iso是哪个大学毕业的)
- 463℃mysql服务怎么启动和关闭?(mysql服务怎么启动和关闭)
- 461℃MySQL server PID file could not be found!失败
- 最近发表
- 标签列表
-
- cmd/c (90)
- c++中::是什么意思 (84)
- 标签用于 (71)
- 主键只能有一个吗 (77)
- c#console.writeline不显示 (95)
- pythoncase语句 (88)
- es6includes (74)
- sqlset (76)
- windowsscripthost (69)
- apt-getinstall-y (100)
- node_modules怎么生成 (87)
- chromepost (71)
- flexdirection (73)
- c++int转char (80)
- mysqlany_value (79)
- static函数和普通函数 (84)
- el-date-picker开始日期早于结束日期 (70)
- asynccallback (71)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- java (73)
- js数组插入 (83)
- mac安装java (72)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)