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

Using Oracle Index Hints in SQL statements

Using Oracle Index Hints in SQL statements
Hints are used to give specific information that we know about our data and application, to Oracle. This further improves the performance of our system. There can be instances where the default optimizer may not be efficient for a certain SQL statements. We can specify HINTS with the SQL statements, to improve the efficiency of those SQL statements.
In this article, we shall see how to specify INDEX hints and what the advantages of the same are.
1      How to specify Hints
The Hints are enclosed in comment, /* comment */, in an SQL statement, and can only be specified with SELECT, DELETE and UPDATE keyword.
SELECT /* comment */ ........ ;
All hints should start with a + sign. This tells the SQL Parser that the SQL has a hint specified with it.
SELECT /*+{hint} */ ........ ;
2      Using INDEX Hints
When you specify an INDEX Hint, the optimizer knows that it has to use the INDEX specified in the hint. In this case, the optimizer does not go for a Full Table Scan nor does it use any other index. In addition, it does not calculate the cost of the Index to be used.
If no INDEX hint is specified the optimizer determines the cost of the each index that could be used to access the table and uses the one with the lower cost.
If there are multiple indexes specified with the Hint then the optimizer has to determine the cost of each index to be used with the specified table. Once that is determined, it uses the Index with the lower cost to access the table. In this case, the optimizer does not do a FULL Table Scan. Also note that, the optimizer may choose to use multiple indexes and then merge the result sets to access the table. This method is used if the cost is low.
Syntax:
/*+ INDEX ( table [index [index]...] ) */
Where:
table specifies the name or alias of the table associated with the index to be scanned.
index specifies an index on which an index scan is to be


相关文档:

使用SQLServer模板来写规范的SQL语句

如果你经常遇到下面的问题,你就要考虑使用SQL Server的模板来写规范的SQL语句了:
SQL初学者。
经常忘记常用的DML或是DDL SQL 语句。
在多人开发维护的SQL中,每个人都有自己的SQL习惯,没有一套统一的规范。
在SQL Server Management Studio中,已经给大家提供了很多常用的现成SQL规范模板。
SQL Server Management ......

连接oracle,sqlserver中数据库的示例代码

一 在Oracle中连接数据库
public class Test1 {
 public static void main(String[] args) {
  try {
   Class.forName("oracle.jdbc.driver.OracleDriver");
   Connection conn = DriverManager.getConnection(
       &nbs ......

oracle不同版本间数据的导入导出


oracle不同版本间数据的导入导出
Oracle的imp/exp组件是我们常用的工具,它的一个操作原则就是向下兼容。下面是据此总结的几个使用规则和相关测试:
 
规则1:低版本的exp/imp可以连接到高版本(或同版本)的数据库服务器,但高版本的exp/imp不能连接到低版本的数据库服务器
 
1.1 使用9i客户端通过imp连 ......

Oracle 10g Statistic数据统计


Oracle 10g statistic数据统计,Oracle会根据这些统计信息来决定是走RBO(Rule-BasedOptimization),还是走CBO(Cost-BasedOptimization),会去选择哪种执行计划更划算,影响是否走相关的索引等.如果是CBO的话,它依靠准确的(或者说比较准确的)统计信息来产生优化的执行路径,如果没有做过统计,CBO也就没有做cost评估的依据 ......

Oracle中NVL2 和NULLIF的用法

NULL指的是空值,或者非法值。
NVL (expr1, expr2)->expr1为NULL,返回expr2;不为NULL,返回expr1。注意两者的类型要一致
NVL2 (expr1, expr2, expr3) ->expr1不为NULL,返回expr2;为NULL,返回expr3。expr2和expr3类型不同的话,expr3会转换为expr2的类型
NULLIF (expr1, expr2) ->相等返回NULL,不等返回ex ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号