Oracle Analyze Table命令

时间:2011-10-21 19:35:45

标签: oracle oracle11g

命令Analyze table tbl compute statistics是DDL还是DML?直觉上,它似乎都不是。 当我在.sql文件中有这个命令时,我需要这样做:

execute immediate 'Analyze table tbl compute statistics'

我对该命令有一个熟悉的问题:GRANT DELETE, INSERT, SELECT, UPDATE ON tbl to user

1 个答案:

答案 0 :(得分:6)

更新 Oracle saysgrantanalyze都是数据定义语言(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.”(11g R2)Analyze table已弃用以收集优化程序统计信息,但对其他内容仍然有用。请改用DBMS_STATS。 (我链接到10g R2的在线Oracle文档。但是过去几天我在Oracle的文档站点遇到了麻烦,10g R2文档消失然后再次出现。)