mysql 常用命令

零 修订记录

序号修订内容修订时间
1新增2022/5/6

一 摘要

本文主要记录常用mysql 命令

二 环境信息

三 记录

(一)基础工具

3.1.1 查看某张表索引

3.1.1.1 mysql 版本

mysql 5.7

3.1.1.2 执行命令
show index from 表名;

show index from tdp_material;

示例

mysql> show index from tdp_material;
+--------------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table        | Non_unique | Key_name       | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| tdp_material |          0 | PRIMARY        |            1 | id          | A         |           0 | NULL     | NULL   |      | BTREE      |         |               |
| tdp_material |          0 | index_material |            1 | group_id    | A         |           0 | NULL     | NULL   |      | BTREE      |         |               |
+--------------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

3.1.2 新建用户和数据库以及授权

以下命令在mysql 5.7 上执行

create database piwigo_db  character set utf8 collate utf8_bin;
create user piwigo_db_user identified by '123456';
grant all privileges on piwigo_db.* to  piwigo_db_user@'%' identified by '123456' with grant option;
grant all privileges on piwigo_db.* to piwigo_db_user@localhost  identified by '123456' with grant option;
flush privileges;

3.1.2 修改表字段属性

alter table 表名 modify column 字段名 数据类型 comment ‘注释’;

alter table dev_project_workload modify column man_month  VARCHAR(20)    COMMENT '人月' ;

3.1.3 新增字段

在某个字段A后面新增一个字段

alter table 表名 add column 新增字段名 数据类别 DEFAULT NULL COMMENT ‘注释’ AFTER 字段A;

alter table dev_project_hr_detail add column demand_reason TEXT DEFAULT NULL COMMENT '需求理由' AFTER demand_date;
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值