Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2418819
  • 博文数量: 392
  • 博客积分: 7040
  • 博客等级: 少将
  • 技术积分: 4138
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-17 13:03
个人简介

范德萨发而为

文章分类

全部博文(392)

文章存档

2017年(5)

2016年(19)

2015年(34)

2014年(14)

2013年(47)

2012年(40)

2011年(51)

2010年(137)

2009年(45)

分类: Mysql/postgreSQL

2011-10-10 11:09:26

作者: | 发布时间: 星期三, 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()可以删除的.

标签:

阅读(1164) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~