免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1260 | 回复: 0

PHP中常用到的SQL语句 [复制链接]

论坛徽章:
0
发表于 2011-12-23 01:08 |显示全部楼层
PHP中常用到的SQL语句

作者: theNbsp | 发布时间: 星期三, 07/27/2011 - 20:31

在PHP中,经常会使用到MySQL语句,下面就是一些经常使用的MySQL语句,能对平时的开发工作能起到些许的作用。

MySQL语句显示数据库或表:
show databases;//然后可以use database_name;
show tables;

MySQL语句更改表名:
alter table table_name rename new_t;

MySQL语句添加列 :
alter table table_name add column c_n column attributes;

MySQL语句删除列:
alter table table_name drop column c_n;

MySQL语句创建索引:
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);

MySQL语句删除索引:
alter table c_table drop index c_n1;

MySQL语句更改列信息:
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;

MySQL语句删除数据库或者表:
drop table table_name;
drop database database_name;//使用mysql_drop_db()可以删除的.

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP