建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > MYSQL学习 > mysql创建索引

mysql创建索引

时间:2015-02-25 09:37:19  来源:免费模板网 作者:风雪 阅读次数 tagsmysql创建索引

索引可以加快mysql 查询速度,那么怎么创建索引呢
创建索引:

alter table c_table add index (tb1,tb2);  --把tb1,tb2添加索引

alter table c_table add unique index_name(c_n);

alter table c_table add primary key(sid);

删除索引:

alter table c_table drop index c_n1;

更改列信息:

alter table t_table change c_1 c_1 varchar(200);

alter table t_table modify 1 c_1 varchar(200);

insert插入语句:

insert into table_name (c_1,c_2)

values (’x1′,1);

update语句:

update table_name set c_1 =1 where c_2=3;

删除数据库或者表:

drop table table_name;

drop database database_name;//使用mysql_drop_db()可以删除的.

显示数据库或表:

show databases;//然后可以use database_name;

show tables;

更改表名:

alter table table_name rename new_t;

添加列 :

alter table table_name add column c_n column attributes;

删除列:

alter table table_name drop column c_n;

本文地址:https://www.freemoban.com/mysql/2015/0225/675.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!