|
原帖由 ZALBB 于 2008-4-8 09:48 发表 ![]()
ORACLE 的官方文档里,哪个地方介绍了此方法? sample 里的种子,与产生随机数存在什么关系?
在select语句的sample子句里面
sample_clause
SAMPLE [BLOCK] ( sample_percent )
sample_clause
The sample_clause lets you instruct Oracle to select from a random sample of rows from the table, rather than from the entire table.
See Also:
"Selecting a Sample: Examples"
BLOCK
BLOCK instructs Oracle to perform random block sampling instead of random row sampling.
See Also:
Oracle9i Database Concepts for a discussion of the difference
sample_percent
sample_percent is a number specifying the percentage of the total row or block count to be included in the sample. The value must be in the range .000001 to (but not including) 100.
Restrictions on Sampling During Queries
You can specify SAMPLE only in a query that selects from a single table. Joins are not supported. However, you can achieve the same results by using a CREATE TABLE ... AS SELECT query to materialize a sample of an underlying table and then rewrite the original query to refer to the newly created table sample. If you wish, you can write additional queries to materialize samples for other tables.
See Also:
"Selecting a Sample: Examples"
When you specify SAMPLE, Oracle automatically uses cost-based optimization. Rule-based optimization is not supported with this clause.
--------------------------------------------------------------------------------
Caution:
The use of statistically incorrect assumptions when using this feature can lead to incorrect or undesirable results.
Selecting a Sample: Examples
The following query estimates the number of orders in the oe.orders table:
SELECT COUNT(*) * 100 FROM orders SAMPLE (1);
The following example creates a sampled subset of the sample table hr.employees table and then joins the resulting sampled table with departments. This operation circumvents the restriction that you cannot specify the sample_clause in join queries:
CREATE TABLE sample_emp AS
SELECT employee_id, department_id FROM employees SAMPLE(10);
SELECT e.employee_id FROM sample_emp e, departments d
WHERE e.department_id = d.department_id
AND d.department_name = 'Sales'; |
|