|
SQL> @LABS/tbsinfo1
SQL> select f.tablespace_name,f.file_name, f.file_id, f.status file_status,
2 t.status tablespace_status, t.contents, t.logging
3 from dba_data_files f, dba_tablespaces t
4 where f.tablespace_name = t.tablespace_name;
TABLESPACE
_NAME FILE_NAME FILE_ID FILE_STAT TABLESPAC CONTENTS LOGGING
---------- ---------------------------------------- ------- --------- --------- --------- ---------
SYSTEM /home/human/oradata/HUMAN/system01.dbf 1 AVAILABLE ONLINEPERMANENT LOGGING
UNDOTBS1 /home/human/oradata/HUMAN/undotbs01.dbf 2 AVAILABLE ONLINEUNDO LOGGING
DRSYS /home/human/oradata/HUMAN/drsys01.dbf 4 AVAILABLE ONLINEPERMANENT LOGGING
INDX /home/human/oradata/HUMAN/indx01.dbf 6 AVAILABLE ONLINEPERMANENT LOGGING
TOOLS /home/human/oradata/HUMAN/tools01.dbf 8 AVAILABLE ONLINEPERMANENT LOGGING
USERS /home/human/oradata/HUMAN/users01.dbf 9 AVAILABLE ONLINEPERMANENT LOGGING
QUERY_DATA /home/human/oradata/HUMAN/query01.dbf 13 AVAILABLE READ ONLY PERMANENT LOGGING
-Read only tablespace ÀÎ Query_Data¸¦ Read Write·Î ¹Ù²Ù°í User hr ÀÌ Data¸¦ Insert
SQL> alter tablespace query_data read write;
SQL> alter user hr quota 1m on query_data;
SQL> conn hr/hr
Connected.
SQL> create table q_emp
2 (id number)
3 tablespace query_data;
Table created.
SQL> insert into q_emp
2 select employee_id from employees;
SQL> conn /as sysdba
Connected.
SQL> shutdown immediate;
2) Failure ¸¦ ¸¸µç´Ù
$ rm -f $HOME/dbs/query01.dbf
$sqlplus '/as sysdba'
SQL> startup
Database mounted.
ORA-01157: cannot identify/lock data file 13 - see DBWR trace file
ORA-01110: data file 13: '/home/human/oradata/HUMAN/query01.dbf'
3) º¹±¸ ½ÃÀÛ
SQL> alter database datafile '/home/human/oradata/HUMAN/query01.dbf' offline;
Database altered.
SQL>
SQL> select name,status from v$datafile;
NAME
----------------------------------------------------------------------
-----------------------------------------------------
STATUS
-------
/home/human/oradata/HUMAN/query01.dbf
OFFLINE
SQL> alter database open;
Database altered.
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
DRSYS ONLINE
INDX ONLINE
TOOLS ONLINE
USERS ONLINE
XDB ONLINE
NANUNE01 ONLINE
NANUNETEMP ONLINE
ISAYA01 ONLINE
TABLESPACE_NAME STATUS
------------------------------ ---------
QUERY_DATA ONLINE
12 rows selected.
SQL> !cp $HOME/ONBACKUP/query01.dbf $HOME/oradata/HUMAN/
SQL>
SQL>
SQL> recover datafile '/home/human/oradata/HUMAN/query01.dbf';
Media recovery complete.
SQL> alter database datafile '$HOME/oradata/HUMAN/query01.dbf' online;
Database altered.
SQL> select count(*) from hr.q_emp;
COUNT(*)
----------
20
SQL> alter tablespace query_data read only; <-- ´Ù½Ã Read Only·Î º¯°æ
Tablespace altered.
SQL> !cp $HOME/oradata/HUMAN/query01.dbf $HOME/ONBACKUP/
--> R/W¿¡¼ R/O·Î º¯°æ µÇ¾úÀ¸¹Ç·Î ´Ù½Ã backupÀ» ¹Þ¾Æ¾ß ÇÑ´Ù.
|