楼主: matrix

怎样回收表空间的空间?

[复制链接]
论坛徽章:
4
生肖徽章2007版:羊
日期:2008-04-17 15:56:40生肖徽章2007版:蛇
日期:2009-08-18 13:22:42
11#
发表于 2005-3-14 14:43 | 只看该作者
最初由 matrix 发布
[B]

我建表和表空间的时候没有制定PCTFREE,PCTUSED,表空间的管理是LOCAL、AUTO的。
默认的情况下PCTFREE,PCTUSED各是多少值啊?
我查了一下user_tables。PCTFREE是10,但是PCTUSED字段是空的,不知道到底是什么意思? [/B]

如果你没有指定,那么ORACLE用以下的默认值,(9i)
PCTFREE: 10
PCTUSED: 40
INITRANS: 1
MAXTRANS: Depends on data block size

使用道具 举报

回复
求职 : 数据库管理员
论坛徽章:
16
授权会员
日期:2006-05-05 16:12:242014年新春福章
日期:2014-02-18 16:41:112013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:05:37生肖徽章2007版:龙
日期:2012-02-07 10:33:222012新春纪念徽章
日期:2012-02-07 09:59:35ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282011新春纪念徽章
日期:2011-02-18 11:43:36ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44ITPUB元老
日期:2007-07-28 10:13:02
12#
发表于 2005-3-14 14:55 | 只看该作者
除以上各位大蝦之方法外,你也可以償試alter tablespace ..... thin

使用道具 举报

回复
论坛徽章:
0
13#
发表于 2005-3-14 15:01 | 只看该作者
看来你是使用了自动段空间管理,所以PCT_USED为空

使用道具 举报

回复
论坛徽章:
0
14#
发表于 2005-3-14 15:02 | 只看该作者
你使用了自动段空间管理,所以PCT_USED为空

使用道具 举报

回复
论坛徽章:
168
马上加薪
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:10:582012新春纪念徽章
日期:2012-01-04 11:49:54蜘蛛蛋
日期:2011-12-05 16:08:56ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41设计板块每日发贴之星
日期:2011-07-22 01:01:02ITPUB官方微博粉丝徽章
日期:2011-06-30 12:30:16管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:33
15#
发表于 2005-3-14 15:06 | 只看该作者
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE    8.1.7.0.0       Production
TNS for 32-bit Windows: Version 8.1.7.0.0 - Production
NLSRTL Version 3.4.1.0.0 - Production


SQL> create tablespace test datafile 'F:\ORACLE\ORADATA\ORCL\TEST01.dbf' size 10
m
  2  /

表空间已创建。

SQL>
SQL> alter user test default tablespace test
  2  /

用户已更改。

SQL>
SQL> drop table t_1
  2  /
drop table t_1
           *
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在


SQL>
SQL> create table t_1
  2  as select * from dba_objects
  3  /

表已创建。

SQL>
SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by ta
blespace_name
  2  /

TABLESPACE_NAME                SUM(BYTES)/1024/1024
------------------------------ --------------------
DRSYS                                    15.8671875
INDX                                     19.9921875
RBS                                      21.9921875
SYSTEM                                    13.859375
TEMP                                     19.9921875
TEST                                      6.6328125
TOOLS                                     9.9921875
USERS                                     3.7421875

已选择8行。
SQL>

SQL> delete t_1
  2  /

已删除24777行。

SQL> commit
  2  /

提交完成。

SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by ta
blespace_name
  2  /

TABLESPACE_NAME                SUM(BYTES)/1024/1024
------------------------------ --------------------
DRSYS                                    15.8671875
INDX                                     19.9921875
RBS                                      19.9921875
SYSTEM                                    13.859375
TEMP                                     19.9921875
TEST                                      6.6328125
TOOLS                                     9.9921875
USERS                                     3.7421875

已选择8行。

SQL>

-- 删除后查询dba_free_space视图,数据没有变化

SQL> column segment_name format a30
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1';

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                   3.359375

SQL>
SQL> insert into t_1 select * from dba_objects
  2  /

已创建24777行。

SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1'
  2  /

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                   3.359375

SQL> commit
  2  /

提交完成。

SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1'
  2  /

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                   3.359375

-- 再次插入

SQL> insert into t_1 select * from dba_objects
  2  /

已创建24777行。

SQL> commit
  2  /

提交完成。

SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1'
  2  /

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                  7.4609375

SQL>


-- 通过truncate清空表数据,视图dba_segments/dba_free_space均即时反应了使用空间的变化
SQL> truncate table t_1
  2  /

表已截掉。

SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1'
  2  /

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                   .0390625

SQL>
SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by ta
blespace_name
  2  /

TABLESPACE_NAME                SUM(BYTES)/1024/1024
------------------------------ --------------------
DRSYS                                    15.8671875
INDX                                     19.9921875
RBS                                      19.9921875
SYSTEM                                    13.859375
TEMP                                     19.9921875
TEST                                       9.953125
TOOLS                                     9.9921875
USERS                                     3.7421875

已选择8行。

SQL>

使用道具 举报

回复
论坛徽章:
168
马上加薪
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:10:582012新春纪念徽章
日期:2012-01-04 11:49:54蜘蛛蛋
日期:2011-12-05 16:08:56ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41设计板块每日发贴之星
日期:2011-07-22 01:01:02ITPUB官方微博粉丝徽章
日期:2011-06-30 12:30:16管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:33
16#
发表于 2005-3-14 15:06 | 只看该作者
-- 改变存储参数pctused

SQL> alter table t_1 pctused 0
  2  /

表已更改。

SQL> insert into t_1 select * from dba_objects
  2  /

已创建24777行。

SQL> insert into t_1 select * from dba_objects
  2  /

已创建24777行。

SQL> commit
  2  /

提交完成。

SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1'
  2  /

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                  7.4609375

SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by ta
blespace_name
  2  /

TABLESPACE_NAME                SUM(BYTES)/1024/1024
------------------------------ --------------------
DRSYS                                    15.8671875
INDX                                     19.9921875
RBS                                      19.9921875
SYSTEM                                    13.859375
TEMP                                     19.9921875
TEST                                        2.53125
TOOLS                                     9.9921875
USERS                                     3.7421875

已选择8行。

SQL>

SQL> delete t_1
  2  /

已删除49554行。

SQL> commit
  2  /

提交完成。

SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1'
  2  /

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                  7.4609375

SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by ta
blespace_name
  2  /

TABLESPACE_NAME                SUM(BYTES)/1024/1024
------------------------------ --------------------
DRSYS                                    15.8671875
INDX                                     19.9921875
RBS                                      12.4921875
SYSTEM                                    13.859375
TEMP                                     19.9921875
TEST                                        2.53125
TOOLS                                     9.9921875
USERS                                     3.7421875

已选择8行。

SQL>
SQL> ALTER TABLE t_1 DEALLOCATE UNUSED
  2  /

表已更改。

SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1'
  2  /

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                     5.3125

SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by ta
blespace_name
  2  /

TABLESPACE_NAME                SUM(BYTES)/1024/1024
------------------------------ --------------------
DRSYS                                    15.8671875
INDX                                     19.9921875
RBS                                      12.4921875
SYSTEM                                    13.859375
TEMP                                     19.9921875
TEST                                      4.6796875
TOOLS                                     9.9921875
USERS                                     3.7421875

已选择8行。

SQL>

-- pctused的数值不会影响可用空间的使用

SQL> select count(*) from t_1
  2  /

  COUNT(*)
----------
         0

SQL> insert into t_1 select * from dba_objects
  2  /

已创建24777行。

SQL> insert into t_1 select * from dba_objects
  2  /

已创建24777行。

SQL> insert into t_1 select * from dba_objects
  2  /

已创建24777行。

SQL> commit;

提交完成。

SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name =
'T_1'
  2  /

SEGMENT_NAME                   BYTES/1024/1024
------------------------------ ---------------
T_1                                  9.0234375

SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by ta
blespace_name
  2  /

TABLESPACE_NAME                SUM(BYTES)/1024/1024
------------------------------ --------------------
DRSYS                                    15.8671875
INDX                                     19.9921875
RBS                                      12.4921875
SYSTEM                                    13.859375
TEMP                                     19.9921875
TEST                                         .96875
TOOLS                                     9.9921875
USERS                                     3.7421875

已选择8行。

SQL>

使用道具 举报

回复
论坛徽章:
0
17#
 楼主| 发表于 2005-3-14 15:07 | 只看该作者
最初由 kele08 发布
[B]看来你是使用了自动段空间管理,所以PCT_USED为空 [/B]


我是使用了自动段空间管理!!!PCT_USED为空什么意思?是0吗?是不是数据块一旦被从freelist中踢出就永远都不会在放到freelist中。

我重新建立表并指定 pctused 70;重建后user_tables中的字段还是空,是不是没有生效。
我还用修改表空间的段空间的管理方式为manul吗?


谢谢!!

使用道具 举报

回复
论坛徽章:
1
授权会员
日期:2009-02-02 10:53:59
18#
发表于 2005-3-14 15:09 | 只看该作者
最初由 matrix 发布
[B]

难道我删除了1000000万行数据后,连1行数据都查不进去吗? [/B]



你del了以后有没有commit啊

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
19#
发表于 2005-3-14 15:14 | 只看该作者
ORA-01653 unable to extend table string.string by string in tablespace string
Cause: Failed to allocate an extent for table segment in tablespace.

Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated

使用道具 举报

回复
论坛徽章:
0
20#
发表于 2005-3-14 15:17 | 只看该作者
在自动段空间管理的方式下,数据块的分配是自动的,所以不需要pct_used参数,NULL并不代表是0

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表