当前位置:首页 > 数据库 > 正文内容

mysql alter、index的操作

root5年前 (2022-01-13)数据库1598

删除字段

alter table user drop name;

添加字段

alter table user add address varchar(255);

修改字段

alter table user change address address text;


修改字段默认值

alter table user alter age set default 18;


修改表名

alter table user rename to user2;


创建索引

create index us_name on user(name);

修改表结构的时候创建索引

alter table user add index us_name(name)

创建表的时候创建索引

create table user (
id int ,
name varchar(100),
index us_name (name)
)


创建唯一索引

create unique index us_name on user(name);

修改表和创建表,只需要把index 换成unique


删除索引

alter table user  frop index us_name;

扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://zhiqiu.top/?id=208

分享给朋友:

相关文章

mysql启动失败 日志InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 3485

mysql报错Ignoring the redo log due to missing MLOG_CHECKPOINT betweenmysql版本:5.7.33系统版本:ubuntu16.04由于电脑突然关闭,跑在VMware里面的mys...

mysql 导出csv格式数据

mysql -e "select * from newsdb.t_hk_stock_news where id <100  ...

postgresql 的安装使用

安装centos系统 9.6版本# Install the repository RPMsudo yum install -y https://download.postgresql.org/pub/repos/yum/repor...

postgresql修改数据存储位置

postgresql修改数据存储位置

最近公司提供了一台新的服务器,同时有一个盘是ssd。同时为了测试postgresql的性能,将数据放置到ssd上系统centos7.9 数据库postgresql-9.6首先停掉数据库systemctl stop pos...

mysql 重置表

truncate table 表名...

mysql数据导入es

将mysql数据取出放到elasticsearch中from datetime import datetime from elasticsearch import Elastic...