2011-10-21 60 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」命令文檔的鏈接)當前已中斷。 –