查询分页的几种Sql写法 摘自:http://www.cnblogs.com/zcttxs/archive/2012/04/01/2429151.html 1.创建测试环境,(插入100万条数据大概耗时5分钟). create database DBTest use DBTest --创建测试表 create table pagetest ( id int identity(1,1) not null, col01 int null, col02 nvarchar(50) null, col03…
MySQL查询不区分大小写的sql写法 mysql查询默认是不区分大小写的 如: select * from some_table where str=‘abc'; select * from some_table where str='ABC'; 得到的结果是一样的,如果我们需要进行区分的话可以按照如下方法来做: 第一种方法: 要让mysql查询区分大小写,可以: select * from some_table where binary str='abc' select * from som…
数据库建表的SQL写法如下: 数据库建表的SQL写法如下: create table dataC( a int identity(1,2) primary key, b varchar(20)) identity(1,2)中的1表示第一条记录的a的值,第二个参数表示递增的步长(本例中,表示步长为2) 在“查询分析器”中要插入数据,直接使用下面的插入方式,无须显示插入字段a的值 insert into dataC values('111')insert into dataC values('2…
数据库SQL优化大总结 小编最近几天一直未出新技术点,是因为小编在忙着总结整理数据库的一些优化方案,特此奉上,优化总结较多,建议分段去消化,一口吃不成pang(胖)纸 一.百万级数据库优化方案 1.对查询进行优化,要尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: select id from t where num is null 最好不要给数…