Chinaunix首页 | 论坛 | 博客
  • 博客访问: 213207
  • 博文数量: 57
  • 博客积分: 1376
  • 博客等级: 中尉
  • 技术积分: 658
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-09 09:51
文章分类

全部博文(57)

文章存档

2012年(1)

2011年(56)

分类: Oracle

2011-02-13 15:11:27

Chap 2: select, where
---------------------
1. Character strings and date values are enclosed in single quotation marks.
Character values are case sensitive, and date values are format sensitive.
The default date format is DD-MON-RR.

2. Between A and B  <====> >= A and <= B

3. ESCAPE : You can use escape to filter the data contains '%' and '_'.
Here is a example:
  1. SQL> select ename from emp where ename like 'Milo\_%' escape('\');

  2. ENAME
  3. ----------
  4. Milo_Luo

4. Operator Priority:
    1    Arithmetic operators
    2    Concatenation operator
    3    Comparison conditions
    4    IS [NOT] NULL, LIKE, [NOT] IN
    5    [NOT] BETWEEN
    6    NOT logical condition
    7    AND logical condition
    8    OR logical condition


You can use () to force a priority changing.


5. ROWNUM :
  1. For each row returned by a query, the ROWNUM pseudocolumn returns a number indicating the order in which Oracle selects the row from a table or set of joined rows. The first row selected has a ROWNUM of 1, the second has 2, and so on.

  2. You can use ROWNUM to limit the number of rows returned by a query, as in this example:

  3. SELECT * FROM employees WHERE ROWNUM < 10;
  4. Conditions testing for ROWNUM values greater than a positive integer are always false. For example, this query returns no rows:

    SELECT * FROM employees
    WHERE ROWNUM > 1;


    The first row fetched is assigned a ROWNUM of 1 and makes the condition false. The second row to be fetched is now the first row and is also assigned a ROWNUM of 1 and makes the condition false. All rows subsequently fail to satisfy the condition, so no rows are returned.


  1. SQL> select * from emp where rownum > 1;

  2. no rows selected

Order by must be place at the end of the statement.

  1. SELECT *|{[DISTINCT] column|expression [alias],...}
  2. FROM table
  3. [WHERE condition(s)]
  4. [ORDER BY {column, expr, alias} [ASC|DESC]];


阅读(1265) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~