ITPub博客

首页 > 数据库 > Oracle > [20230224]改动数据文件小技巧.txt

[20230224]改动数据文件小技巧.txt

原创 Oracle 作者:lfree 时间:2023-02-24 21:19:29 0 删除 编辑

[20230224]改动数据文件小技巧.txt

--//有时候需要resize数据文件,我一般使用文件名,今天看别人操作可以直接使用文件号完成,这样简单明了,不用输入文件名.减少出错
--//的概率,测试看看.

--//例子:
alter database tempfile 1 resize 1024M;
alter database tempfile 1 autoextend off;

1.环境:
SYS@book> @ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.测试:
SYS@book> alter database tempfile 1 autoextend off;
Database altered.

SYS@book> select * from V$TEMPFILE
  2  @ pr
==============================
FILE#                         : 1
CREATION_CHANGE#              : 925793
CREATION_TIME                 : 2015-11-24 09:11:14
TS#                           : 3
RFILE#                        : 1
STATUS                        : ONLINE
ENABLED                       : READ WRITE
BYTES                         : 158334976
BLOCKS                        : 19328
CREATE_BYTES                  : 20971520
BLOCK_SIZE                    : 8192
NAME                          : /mnt/ramdisk/book/temp01.dbf
PL/SQL procedure successfully completed.
--//158334976/1024/1024 = 151M.

SYS@book> alter database tempfile 1 resize 500M;
Database altered.

SYS@book> select * from V$TEMPFILE
  2  @ pr
==============================
FILE#                         : 1
CREATION_CHANGE#              : 925793
CREATION_TIME                 : 2015-11-24 09:11:14
TS#                           : 3
RFILE#                        : 1
STATUS                        : ONLINE
ENABLED                       : READ WRITE
BYTES                         : 524288000
BLOCKS                        : 64000
CREATE_BYTES                  : 20971520
BLOCK_SIZE                    : 8192
NAME                          : /mnt/ramdisk/book/temp01.dbf
PL/SQL procedure successfully completed.

--//修改回来.
SYS@book> alter database tempfile 1 resize 151M;
Database altered.

--//测试改动数据文件可以吗?测试如下:
SYS@book> alter database datafile 4 resize 380M;
Database altered.

--//OK没有问题.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2936975/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969582