2011-10-21 59 views
2

命令Analyze table tbl compute statistics是DDL还是DML?直觉上,它似乎既不是。 当我.sql文件有这个命令做我需要做的:Oracle分析表命令

execute immediate 'Analyze table tbl compute statistics' 

我对命令smiliar问题:GRANT DELETE, INSERT, SELECT, UPDATE ON tbl to user

+1

'ANALYZE'现在已被弃用'DBMS_STATS'。 –

回答

5

UPDATE甲骨文says这两个grantanalyze是数据定义语言(DDL)语句。他们显然没有区分DDL和数据控制语言(DCL)。

如果从PL/SQL内执行,则需要execute immediateDBMS_SQL

而且, “Do not use the COMPUTE and ESTIMATE clauses of ANALYZE to collect optimizer statistics.”(10gR2中) “For the collection of most statistics, use the DBMS_STATS package. ... Use the ANALYZE statement (rather than DBMS_STATS) for statistics collection not related to the cost-based optimizer.”(11克R2)Analyze table已经废弃了收集优化统计信息,但仍然有用的其他东西。改为使用DBMS_STATS。 (我链接到10g R2的在线Oracle文档,但过去几天我一直在使用Oracle的文档站点,10g R2文档消失,然后再次出现。)

+0

除一个之外的所有链接(用于10.2的“ANALYSE”命令文档的链接)当前已中断。 –