Академический Документы
Профессиональный Документы
Культура Документы
1. The Oracle 7.3, and 8.0.3, and 8.1.5 manuals are not supposed to be online.
The 9i manuals are supposed to be online (free username/password required)
2. A PL/SQL package to generate random numbers
What if you want a random number in the where clause, like, so you can choose
1/10 of the rows at random? Use a hash instead.
3. The biggest difference between Oracle and everyone else is the locking
mechanism. Everyone else gets share locks on data when they query it. That
means other queries can also see the data, but queries block writes and
writes block queries. (Update: the default for everyone else, for for example
for DB2, is for queries not to block writes. Instead they show any data
committed at the time the query internally fetches the data. This means each
query result can be internally inconsistent, but it allows greater concurrency.)
Oracle doesn't have share locks. Instead it uses snapshots, which are points
in time. A query looks at the data as of some point in time. If someone
changes the data later, that's OK, the query still sees the old version of the
data. Each query result is internally consistent, but consecutive queries may
not be consistent with one another. Queries don't block writes and writes
don't block queries. Writes still block writes. Both share locks and snapshots
are reasonable concurrency models, but they aren't the same. It's wrong to
think in terms of one when working with the other.
4. Derived tables (from-clause subqueries, inline views):
5. select * from (select * from emp);
6. insert into (select deptno from dept)
7. select trunc(a) from (select sum(empno)/5000 a from emp);
This has the same effect as if you used a view. It is useful for queries that
have a repeated complex expression; for example
It's also useful when you want to use one of the values found by a subquery,
for example when deleting all outdated entries from a log:
As of 9i, inline views can also be expressed with a "WITH clause", for example
with sub1 as (select deptno, avg(sin(empno)) x from emp group by
deptno)
select a.deptno, a.x, b.x from sub1 a, sub1 b where a.deptno >
b.deptno;