网站首页 > 知识剖析 正文
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 '注释内容';
修改表的表字段注释
注意:字段名和字段类型照写就行,如果之前有规定长度 这里也要指定一下
猜你喜欢
- 2025-05-30 mysql 之json字段详解(多层复杂检索)
- 2025-05-30 SQL注入基础
- 2025-05-30 MySQL新手必看!15个高频SQL语句,让你从菜鸟变大神!
- 2025-05-30 MySQL 避坑指南之隐式数据类型转换
- 2025-05-30 MySQL进阶系列:SQL执行计划分析及执行方式
- 2025-05-30 java 培训 MySQL 一次性插入多行数据的操作
- 2025-05-30 数据库迁移有什么技巧?|分享强大的database迁移和同步工具
- 2025-05-30 全网最硬核操作:10亿数据如何最快插入MySQL?
- 2025-05-30 「SQL」MySQL之索引
- 2025-05-30 Mysql的varchar字段按照数字来排序
- 05-30mysql 之json字段详解(多层复杂检索)
- 05-30SQL注入基础
- 05-30MySQL新手必看!15个高频SQL语句,让你从菜鸟变大神!
- 05-30MySQL 避坑指南之隐式数据类型转换
- 05-30MySQL进阶系列:SQL执行计划分析及执行方式
- 05-30java 培训 MySQL 一次性插入多行数据的操作
- 05-30数据库迁移有什么技巧?|分享强大的database迁移和同步工具
- 05-30全网最硬核操作:10亿数据如何最快插入MySQL?
- 最近发表
- 标签列表
-
- xml (46)
- css animation (57)
- array_slice (60)
- htmlspecialchars (54)
- position: absolute (54)
- datediff函数 (47)
- array_pop (49)
- jsmap (52)
- toggleclass (43)
- console.time (63)
- .sql (41)
- ahref (40)
- js json.parse (59)
- html复选框 (60)
- css 透明 (44)
- css 颜色 (47)
- php replace (41)
- css nth-child (48)
- min-height (40)
- xml schema (44)
- css 最后一个元素 (46)
- location.origin (44)
- table border (49)
- html tr (40)
- video controls (49)