Home > July, 2016 存档

Oracle SHRINK 收缩

评分 0.00, 满分 5星 0 票 5 comments

快速获取schemas 下可以进行shrink 收缩的表。

SELECT dt.owner,
         (CASE WHEN NVL (ind.cnt, 0) < 1 THEN 'Y' ELSE 'N' END) AS can_shrink
    FROM dba_tables dt,
         (  SELECT table_name, COUNT (*) cnt
              FROM dba_indexes di
             WHERE index_type LIKE 'FUNCTION-BASED%'
          GROUP BY table_name) ind
   WHERE     dt.table_name = ind.table_name(+)
         AND dt.table_name NOT LIKE 'AQ$%'
         AND dt.table_name NOT LIKE 'BIN$%'
         AND dt.owner = '&ownername'
ORDER BY 1, 2;

如果无法收缩 Oracle 会提示如下:
ORA-10631: SHRINK clause should not be specified for this object