2019-07-09

对数据库的操作

show databases;//显示库

create database user;//创建user的库

drop database user;//删除user的库

use database;//使用库


插入

insert into 表名 (username,password,nickname) value ('ysh',"123","杨少辉”);

查询

select * from t_user;//查询表中的所有内容

drop table t_user;//删除表

show tables;//查询所有表

desc t_user;//查询t_user表的结构

索引

更新唯一键 & 删除唯一键

错误的删除方法:alter table 表名 drop unique key;

alter table 表名 drop index 索引名字;

MySQL中提供了多种索引

主键索引:primary key

唯一索引:unique key

全文索引:fulltextindex

普通索引:index

创建

create [unique] index 索引名 on 表名(字段名(长度));

alter 表名 add [unique] index [索引名] on (字段名(长度));

删除:drop index [索引名] on 表名;

查看:show index from 表名\G

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。