欢迎投稿

今日深度:

MySQL,

MySQL,


数据表的操作:

查看数据表:
desc [表名]

show table [表名]

修改数据表:
修改表名:alter table [旧表名] rename to [新表名];

修改字段名:alter table [表名] change [旧字段名] [新字段名] [新字段名]

修改字段的数据类型:alter table [表名] modify [字段名] [数据类型]

添加字段:alter table [表名] add [新字段名] 数据类型(约束)

删除字段:alter table [表名] drop [字段名]

修改字段的排列位置:alter table [表名] modify [字段名1] [数据类型] first/after [字段名2]

删除数据表:drop table [表名]

添加数据: insert into 表名 values( ),( ),( );

更新数据: updata 表名 set id=01,name=' ' where id=1;

删除数据: delete from 表名 where id<5;

表的约束:
主键约束:
primary key:单字段约束,多字段约束

非空约束:
    ...not null

唯一约束:
    ...unique

默认约束:
    ...default 0

索引: 是为了高效率查找特定的数据,提高查询速度

删除索引:
alter table drop index 索引名

drop index 索引名 on 

创建索引:

创建表时创建索引:

普通索引:   index([字段名])

唯一索引:   unique index [unique_id(id asc)]    //asc,升序 desc,降序

全局索引:   fulltext index [fulltext_id(id)]

单列索引:   index [single_name(name(20))]

多列索引:   index multi(id,name(20))

空间索引:   spatial index nm(name)

在已建立表上创建索引:

create index

create [unique/spatial/fulltext] index [索引名] on 表名(id(10),name(20))

alter table

alter table 表名 add [unique/spatial/fulltext] index 索引名(id(20) asc)

单表查询:
简单查询:
select语句:
按条件查询:
where
in
between and
null
distinct
like: '%' 通配符查询;'_' 通配符查询
and(多条件查询)
or
高级查询:select
聚合函数:
count(),sum(),avg(),max(),min()
查询结果排序:
select * from s1 order by id adc,item desc
分组查询:

www.htsjk.Com true http://www.htsjk.com/Mysql/39856.html NewsArticle MySQL, 数据表的操作: 查看数据表: desc [表名] show table [表名] 修改数据表: 修改表名:alter table [旧表名] rename to [新表名]; 修改字段名:alter table [表名] change [旧字段名] [新字段名] [新字...
相关文章
    暂无相关文章
评论暂时关闭