VMS: ALTER TABLESPACE/DATABASE TO RENAME FILES on VMS [ID 9560.1]
VMS: ALTER TABLESPACE/DATABASE TO RENAME FILES on VMS [ID 9560.1]
PURPOSE
This article describes the use of ALTER DATABASE and ALTER TABLESPACE commands
to change the distribution of database files on disks, and to add files to
existing tablespaces on VMS. Advantages of using ALTER TABLESPACE are also
discussed.
SCOPE & APPLICATION
This article, while originally written for Oracle6, can be used by DBAs
renaming database files on Oracle6, Oracle7 or Oracle8.
Note: if there are large number of updates needed, it might be easier to
recreate the controlfile which allows the relocating of files.
See Note:1012929.6 HOW TO RECREATE THE CONTROL FILE
RELATED DOCUMENTS
Note:10662.1 UNIX: RENAMING DATABASE FILES ON UNIX
ADDITIONAL KEYWORDS
Renaming; Rename
Prior to using ALTER DATABASE or ALTER TABLESPACE to make structural changes
to your database you should ensure that you have a recent backup.
After making structural changes to the database, if the database is running
in ARCHIVELOG mode you can backup only the control file and any data files
that were added after the last database backup. However, if the database
is running in NOARCHIVELOG mode then you should do a full database backup.
(See the Oracle Database Administrator's Guide for a complete discussion of
backup and recovery.)
The following syntax is used in the examples and denotes the expanded file
specification. Note that the string can include concealed device logicals.
:[
ALTER DATABASE
--------------
The ALTER DATABASE command is used to rename system tablespace files
and redo log files. ALTER DATABASE can also be used to rename non-system
tablespace files. However, by using the ALTER TABLESPACE command this
can be accomplished without shutting down the database.
RENAME A SYSTEM TABLESPACE OR REDO LOG FILE OR MOVE THE FILE TO A NEW LOCATION
1. Get the fully qualified file name from the data dictionary
and then shutdown the database.
SQL> connect internal
SQL> select FILE_NAME from DBA_DATA_FILES;
SQL> select NAME from V$LOGFILE;
SQL> disconnect
SQL> shutdown
2. Copy the file to the new location using the backup command.
(The backup qualifier "/delete" will delete the original file
if the copy is successful.)
$ backup/ignore=(interlock,nobackup) -
:[] -
:[]
3. Mount the database in exclusive mode, but do not open it.
SQLDBA> startup exclusive mount
4. Rename the file in ORACLE using the exact string selected from
DBA_DATA_FILES or V$LOGFILE (Step 1.)
SQL> connect internal
SQL> ALTER DATABASE
SQL> rename file ':[]'
SQL> to ':[]';
SQL> ALTER DATABASE open;
5. Backup the control file and any data files added after the last
backup or do a complete database backup using your existing backup
routine.
SQL> ALTER DATABASE backup controlfile
SQL> to ':[]';
SQL> ALTER TABLESPACE begin backup;
SQL> host
$ backup/ignore=(interlock,nobackup) -
:[] -
:[] ! repeat for each file
$ logoff
SQL> ALTER TABLESPACE end backup;
ALTER TABLESPACE
----------------
The ALTER TABLESPACE command is used to rename non-system tablespace files
and to add files to existing tablespaces. Note: The ALTER DATABASE command
must be used to rename system tablespace files
RENAME A NON-SYSTEM TABLESPACE FILE OR MOVE IT TO A NEW LOCATION
1. Get the fully qualified file name from the data dictionary.
SQL> connect internal
SQL> select FILE_NAME from DBA_DATA_FILES;
2. If possible, startup the database in DBA mode to prevent users
from accessing the tablespace.
SQL> shutdown
SQL> startup dba open
3. Take the tablespace containing the file to be moved offline.
SQL> connect internal
SQL> ALTER TABLESPACE offline;
4. Copy the file to the new location using the backup command.
(The backup qualifier "/delete" will delete the original file
if the copy is successful.)
$ backup/ignore=(interlock,nobackup) -
:[] -
:[]
5. Rename the file in ORACLE using the exact string from the FILE_NAME
column of the data dictionary view DBA_DATA_FILES (Step 1.)
SQL> connect internal
SQL> ALTER TABLESPACE
SQL> rename datafile ':[]'
SQL> to ':[]';
6. Bring online the tablespace containing the file that was moved.
SQL> connect internal
SQL> ALTER TABLESPACE online;
7. Startup the database in NORMAL mode if it was running in DBA mode.
SQL> shutdown
SQL> startup open
ADD A FILE TO A TABLESPACE
1. Add the file to the tablespace, where is in bytes.
SQL> connect internal
SQL> ALTER TABLESPACE
SQL> add datafile ':[]'
SQL> size reuse;
---------------------------------------------------------------------------
Oracle Worldwide Customer Support
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-753284/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- VMS 常用命令小注
- Rename Tablespace in Oracle database 10gOracleDatabase
- VMS 常用命令小注(4)
- VMS 常用命令小注(3)
- VMS 常用命令小注(2)
- alter database datafile offline and alter database tablespace ...offlineDatabase
- ALTER DATABASE 與 ALTER TABLESPACE OFFLINE的區別Database
- 【TABLESPACE】使用“ALTER TABLESPACE”命令的“RENAME”功能實現表空間快速重新命名
- alter database datafile offline drop 與 alter tablespace drop datafile 區別Database
- 【TABLESPACE】“ALTER TABLESPACE”命令的“RENAME”功能在重新命名錶空間能力上的測試
- alter database drop datafile 與 drop tablespace file 的區別Database
- How to Rename Tablespace In Oracle10gOracle
- alter database in OracleDatabaseOracle
- How does one rename a database?Database
- alter database create datafileDatabase
- alter database create datafile '' as ''Database
- Can one rename a database user (schema)?Database
- alter database和alter system和alter session的區別DatabaseSession
- alter database open resetlogs;Database
- alter database offline 與 alter database offline drop效果比對Database
- How To Recreate A Database Using TTS (Transportable TableSpace) [ID 733824.1]DatabaseTTS
- 2.5 Overview of Tablespaces and Database Files in a CDBViewDatabase
- alter database disable thread 2Databasethread
- ALTER DATABASE RESETLOGS 的作用Database
- DATA GUARD 中alter database 命令Database
- ALTER DATABASE DATAFILE OFFLINEDatabase
- 忍不住問下alter system 和alter database的區別Database
- Oracle DBA命令參考——alter databaseOracleDatabase
- How to Move or Copy a Tablespace to Another Database (61)Database
- 資料庫審計(create/alter/drop table、user、tablespace)資料庫
- ALTER DATABASE CLEAR UNARCHIVED LOGFILE的使用DatabaseHive
- alter database ... create datafile的原理及用途Database
- alter database datafile 4 offline drop;Database
- 恢復一則 alter database create datafile '' as ''Database
- Tablespace Management Enhancements in Oracle Database 10gOracleDatabase
- How to move ASM database files from one diskgroup to anotherASMDatabase
- Alter database datafile resize ORA-03297 原因解析Database
- UNRECOVERABLE DATAFILE clause in the ALTER DATABASE CLEAR LOGFILE statementDatabase