网站首页 > 技术文章 正文
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# 提效实用干货
- 最近发表
- 标签列表
-
- cmd/c (64)
- c++中::是什么意思 (83)
- 标签用于 (65)
- 主键只能有一个吗 (66)
- c#console.writeline不显示 (75)
- pythoncase语句 (81)
- es6includes (73)
- sqlset (64)
- windowsscripthost (67)
- apt-getinstall-y (86)
- node_modules怎么生成 (76)
- chromepost (65)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- & (66)
- java (73)
- js数组插入 (83)
- linux删除一个文件夹 (65)
- mac安装java (72)
- eacces (67)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)