获取某个对象的元数据;
生产库中索引和表是IO分离存储的.索引不需要备份,而且表的更改索引也会联动更改,即使备份也毫无意义
即使索引表空间损坏,索引的定义也存储在数据字典中,取出元数据重建即可
desc dbms_metadata
如何取元数据
dbms_metadata.get_ddl('类型','对象','模式')
DBMS_METADATA.GET_DDL('TABLESPACE','USERS')
--------------------------------------------------------------------------------
CREATE TABLESPACE "USERS" DATAFILE
'/oracle/oracle/oradata/tjydxc/users01.dbf' SIZE 5242880
AUTOEXTEND ON NEXT 1310720 MAXSIZE 32767M,
'/oracle/oracle/oradata/tjydxc/users02.dbf' SIZE 2147483648,
'/oracle/oracle/oradata/tjydxc/users03.dbf' SIZE 2147483648,
'/oracle/oracle/oradata/tjydxc/users04.dbf' SIZE 2147483648,
'/oracle/oracle/db_1/dbs/D:oracleproduct10.2.0oradatatjydUSERS_02.dbf' SIZE 21
47483648
AUTOEXTEND ON NEXT 8388608 MAXSIZE 32767M
LOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT AUTO
ALTER DATABASE DATAFILE
'/oracle/oracle/oradata/tjydxc/users01.dbf' RESIZE 10321133568
取scott用户下所有表的元数据
SQL> select (select dbms_metadata.get_ddl('TABLE',table_name,owner) from dual)
from dba_tables where owner='SCOTT';
取scott用户下所有索引的元数据
SQL> select (select dbms_metadata.get_ddl('INDEX',index_name,owner) from dual)
from dba_indexes where owner='SCOTT';
其他参考:
配置rman备份文件的存放位置;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/home/oracle/archive/_%U';
创建控制文件 并且修改实例名:
CREATE CONTROLFILE set DATABASE "ora" RESETLOGS NOARCHIVELOG