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


您的位置:首页 > PHP学习 > PHP常用MySql操作命令

PHP常用MySql操作命令

时间:2015-02-11 11:26:11  来源:免费模板网 作者:风雪 阅读次数 tags命令常用

本文介绍一写基本的操作数据库命令,创建数据库,删除,修改,增加列等命令,请看下文

显示数据库或表:

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;

创建索引:

alter table c_table add index (c_n1,c_n2);

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()可以删除的.

本文地址:https://www.freemoban.com/php/2015/0211/501.html

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

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

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