易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL分页查询

thunder:
1.MYSQL实现
mysql> select * from user;
+----+----------+----------+-----------------+
| ID | username | password | email           |
+----+----------+----------+-----------------+
|  1 | admin    | admin    | abc@yahoo.cn    |
|  2 | thomas   | 159753   | thomas@yahoo.cn |
|  3 | thomas1  | 159753   | thomas@yahoo.cn |
|  4 | huhu     | 159753   | hu@yahoo.cn     |
|  5 | fdg      | dfg      | fdg             |
|  6 | sdf      | sd       | sdf@yahoo.cn    |
|  7 | d        | d        | d@d.cn          |
+----+----------+----------+-----------------+
7 rows in set (0.00 sec)
mysql> select * from user limit 3,2;
+----+----------+----------+-------------+
| ID | username | password | email       |
+----+----------+----------+-------------+
|  4 | huhu     | 159753   | hu@yahoo.cn |
|  5 | fdg      | dfg      | fdg         |
+----+----------+----------+-------------+
2 rows in set (0.00 sec)
mysql>
===================================================
2.MSSQLServer实现
select top 5 function_id,function_name from d_function
where function_id not in (select top 5 function_id from d_function)
6 月统计
7 部门查询
8 公司查询
9 工程招标
10 工程总结


相关文档:

SQL SERVER 2005 数据库状态为“可疑”的解决方法

--MyDB为修复的数据名
USE MASTER
GO
SP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDE
GO
ALTER DATABASE MyDB SET EMERGENCY
GO
sp_dboption 'MyDB', 'single user', 'true'
GO
DBCC CHECKDB('MyDB','REPAIR_ALLOW_DATA_LOSS')
GO
ALTER DATABASE MyDB SET ONLINE
GO
sp_configure 'allow updates ......

动态sql语句基本语法

1 :普通SQL语句可以用Exec执行
      例:      Select * from tableName
                Exec('select * from tableName')
        & ......

Oracle 动态SQL返回单条结果和结果集

Oracle 动态SQL返回单条结果和结果集
1. DDL 和 DML
/**//*** DDL ***/
begin
    EXECUTE IMMEDIATE 'drop table temp_1';
    EXECUTE IMMEDIATE 'create table temp_1(name varchar2(8))';
end;
/**//*** DML ***/
declare
    v_1 varchar2(8);
 & ......

Oracle的sql语句优化

 在学习SQL时看到的一片很好的文章,特贴出来和大家一起分享!
我们要做到不但会写SQL,还要做到写出性能优良的SQL语句。
(1)选择最有效率的表名顺序(只在基于规则的优化器中有效):
Oracle的解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving table)将被最先处 ......

sql语句优化3


 
低效: (索引失效)
SELECT … from DEPARTMENT WHERE DEPT_CODE IS NOT NULL;
高效: (索引有效)
SELECT … from DEPARTMENT WHERE DEPT_CODE >=0;
(27)总是使用索引的第一个列:
如果索引是建立在多 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号