转自:http://blog.csdn.net/xys_777/article/details/5711128--分组取最大最小常用sql--测试环境if OBJECT_ID('tb') is not null drop table tb;gocreate table tb(col1 int,col...
分类:
数据库 时间:
2015-05-13 19:27:12
阅读次数:
145
【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` i...
分类:
数据库 时间:
2015-05-06 21:13:58
阅读次数:
179
--删除主键alter table 表名 drop constraint 主键名--添加主键alter table 表名 add constraint 主键名 primary key(字段名1,字段名2……)--添加非聚集索引的主键alter table 表名 add constraint 主键名 ...
分类:
数据库 时间:
2015-05-05 12:12:59
阅读次数:
191
一 插入多行数据的几种方式1 insert into target_table(column1,column2) select column1,5 from source_table;target_table 表存在的时候2 select * into target_table from sourc...
分类:
数据库 时间:
2015-05-04 13:45:07
阅读次数:
163
1.INSERT(往数据表里插入记录的语句)INSERTINTO表名(字段名1,字段名2,……)VALUES(值1,值2,……);INSERTINTO表名(字段名1,字段名2,……)SELECT字段名1,字段名2,……FROM另外的表名;字符串类型的字段值必须用单引号括起来,例如:’GOODDAY’...
分类:
数据库 时间:
2015-04-23 23:25:05
阅读次数:
269
目录1、SQL语句分类2、DDL语句3、DML语句4、DCL语句5、事务相关语句6、mysql查询 6.1、单表简单查询 6.2、多表组合查询 6.2.1、联结查询(交叉联结,内联结,外联结(左外联结、右外联结)) 6.2.2、联合查询(UNION) 6.2.3、内联结 6....
分类:
数据库 时间:
2015-04-22 13:21:04
阅读次数:
202
【转】sql 创建表、删除表 增加字段 删除字段操作下面是Sql Server 和 Access 操作数据库结构的常用Sql,希望对你有所帮助。新建表:create table [表名]([自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,[字段1] nVarChar(...
分类:
数据库 时间:
2015-04-11 17:44:46
阅读次数:
166
多对多判断select a.* from Temp2 a (nolock) where not exists(select * from Temp1 where 年月=a.年月 and 水表代码=a.水表代码 and 水价分类=a.水价分类) order by 小计SELECT * FROM ...
分类:
数据库 时间:
2015-04-10 19:40:00
阅读次数:
185
目录1、SQL语句分类2、DDL语句3、DML语句4、DCL语句5、事务相关语句6、mysql查询6.1、单表简单查询6.2、多表组合查询6.2.1、联结查询(交叉联结,内联结,外联结(左外联结、右外联结))6.2.2、联合查询(UNION)6.2.3、自联结6.3、子查询6.3.1、WHERE子查询6.3.2、FROM子查询..
分类:
数据库 时间:
2015-04-07 19:53:45
阅读次数:
217
导入数据对于MyISAM存储引擎的表,可以通过以下方式快速地导入大量数据alter table tbl_name disable keys; //关闭表非唯一索引的更新loading the dataalter table tbl_name enable keys;如果是空表,默认是先导入数据然后才...
分类:
数据库 时间:
2015-04-07 17:08:26
阅读次数:
189