设为首页 加入收藏

TOP

mysql常用sql语句(一)
2015-11-21 01:37:55 来源: 作者: 【 】 浏览:0
Tags:mysql 常用 sql 语句
【1】清空表语句

truncate table fke_message;

【2】重设自增字段起始值
alter table fke_message auto_increment = 10001;



【3】常用建表语句

DROP TABLE IF EXISTS `fke_message`;
CREATE TABLE `fke_message` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `username` varchar(40) NOT NULL DEFAULT '' COMMENT '用户名',
  `tel` varchar(20) NOT NULL DEFAULT '' COMMENT '电话号码',
  `email` varchar(40) NOT NULL DEFAULT '' COMMENT '电子邮箱',
  `msginfo` varchar(255) NOT NULL DEFAULT '' COMMENT '留言信息',
  `createdate` int(11) NOT NULL DEFAULT '0' COMMENT '时间戳',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



【4】常用查询语句

1. 统计用户量

select count(distinct id) from fke_member


2. 增加字段

alter table e_down add soft_version1 varchar(50) NOT NULL default '' ;


3. 修改字段类型

alter table address modify column city varchar(50) NOT NULL default '';


4. 添加索引

alter table member add index id_index(id);


【5】 数据库创建语句

create database test default CHARACTER SET utf8 COLLATE utf8_general_ci;



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇从mysql读取大量数据时的实践 下一篇mysql数据类型总结

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: