网站首页 > 技术文章 正文
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-08-31 HashMap详解_hashmap lru
- 2025-08-31 孩子们的游戏(圆圈中最后剩下的数)
- 2025-08-31 一招教你搞定西门子博图SCL编程语句中FOR循环指令,so easy
- 2025-08-31 JAVA序列化那些事儿_java序列化方式和作用
- 2025-08-31 雨刮器的INT功能你真的会用吗?别再当摆设了,老司机手把手教你
- 2025-08-31 认识变量与常量_变量与常量的定义
- 2025-08-31 PLC数学函数有哪些呢_plc常用的数学计算
- 2025-08-31 python中字典详解及使用_python里字典怎么用
- 2025-08-31 算法“动态规划”最佳实践——背包问题
- 2025-08-31 大语言模型解释Python 命令行参数详解
- 最近发表
- 标签列表
-
- cmd/c (90)
- c++中::是什么意思 (84)
- 标签用于 (71)
- 主键只能有一个吗 (77)
- c#console.writeline不显示 (95)
- pythoncase语句 (88)
- es6includes (74)
- sqlset (76)
- apt-getinstall-y (100)
- node_modules怎么生成 (87)
- chromepost (71)
- flexdirection (73)
- c++int转char (80)
- mysqlany_value (79)
- static函数和普通函数 (84)
- el-date-picker开始日期早于结束日期 (76)
- js判断是否是json字符串 (75)
- c语言min函数头文件 (77)
- asynccallback (87)
- localstorage.removeitem (77)
- vector线程安全吗 (70)
- java (73)
- js数组插入 (83)
- mac安装java (72)
- 无效的列索引 (74)