最近在看小布老师的Oracle培训视频,以下是我跟着做的部分练习,现在整理出来,以备以后查看,不敢独享,就贴出来。当然,因为本人太懒,只要本人觉得看的懂的都没加注解,万望广大网友见谅。
$ lsnrctl start 启动监听
SQL> drop user SGTEST2 cascade;
SQL> drop tablespace EAS_D_SGTEST2_STANDARD including contents and datafiles;
SQL> SET TIMING ON
SQL> show sga;
SQL> select component, granule_size from v$sga_dynamic_components;
SQL> SELECT sql_text FROM v$sqlarea WHERE executions < 5 ORDER BY UPPER(sql_text); 执行小于5次的SQL语句
SQL> SELECT sql_text,parse_calls,executions FROM v$sqlarea ORDER BY parse_calls;
SQL> startup nomount
SQL> startup mount
SQL> startup open
SQL> alter database mount
SQL> alter database open [read only]
SQL> startup restrict 受限模式
SQL> alter system enable restricted session 受限模式
SQL> create user boobooke identified by bbk; 创建用户boobooke 密码为bbk
SQL> grant connect, resource to boobooke 授权
SQL> alter system set parameter=?
SQL> select sid, serial#, username from v$session;
SQL> alter system kill session 'sid,serial#'; 杀死连接会话
SQL> alter session set SQL_TRACE=true 查看/u01/admin/wilson/udump下的用户*.crc文件
SQL> select username,account_status from dba_users; 查看所有用户及状态
SQL> alter user hr account unlock; 开锁
SQL> alter user hr identified by hr; 重设密码才可用
$ orapwd file=orapwbbk password=123456 entries=10
SQL> create pfile from spfile;
SQL> startup pfile=$ORACLE_HOME/dbs/initwilson.ora
SQL> show parameter control
SQL> select dbid,name from v$database;
控制文件
SQL> ALTER SYSTEM SET control_files =
'$HOME/ORADATA/u01/ctrl01.ctl',
'$HOME/ORADATA/u02/ctrl02.ctl' SCOPE=SPFILE;
SQL> shutdown immediate
$ cp $HOME/ORADATA/u01/ctrl01.ctl $HOME/ORADATA/u02/ctrl02.ctl
SQL> startup
SQL> select group#,thread#,sequence#,status from v$log;
SQL> alter system switch logfile;
SQL> alter system checkpoint;
SQL> alter database drop logfile group 3
SQL> col member format a50;
SQL> select * from v$logfile;
SQL> alter database add logfile group 4
2 ('/u01/oradata/wilson/redo04.log') size 50M; 添加组
SQL> alter database add logfile member
2 '/u01/oradata/wilson/redo04a.log' to group 4; 往组里加成员
SQL> select * from v$log_history;
SQL> select instance_name, archiver from v$instance; 查看归档模式
SQL> select log_mode from v$database;
SQL> select * from v$tablespace;
SQL> col tablespace_name a10
SQL> select file_name, tablespace_name from dba_data_files;
SQL> create tablespace pual datafile
2 '/u01/oradata/wilson/paul01.dbf' size 20M; 创建表空间
SQL> desc database_properties;
SQL> select * from database_properties;
SQL> select tablespace_name,contents,extent_management from dba_tablespaces;
SQL> alter database default temporary tablespace mytemp;
SQL> create tablespace wenchuan
2 datafile '/u01/oradata/wilson/wenchuan01.dbf' size 20M
3 extent management local uniform size 128k;
SQL> create user dz identified by dz default tablespace wenchuan;
SQL> grant connect,resource to dz;
SQL> alter tablespace wenchuan read only;
SQL> alter tablespace wenchuan read write;
SQL> alter tablespace wenchuan offline;
SQL> alter tablespace wenchuan online;
SQL> alter tablespace wenchuan add datafile
2 '/u01/oradata/wilson/wenchuan02.dbf' size 20M
3 autoextend on next 10M maxsize 100M; 新增数据文件让其自动增长
SQL> alter database datafile '/u01/oradata/wilson/wenchuan01.dbf'
2 autoextend on next 10M maxsize 100M; 改变原文件让其自动增长
ALTER DATABASE
DATAFILE 'F:\oradata\sgtest2\EAS_D_SGTEST2_STANDARD.ORA'
AUTOEXTEND ON
NEXT 50M
MAXSIZE UNLIMITED;
SQL> select file_name,tablespace_name, autoextensible from dba_data_files; 查看数据文件的autoextend(自动增长)状态
SQL> select file_name,tablespace_name,bytes from dba_data_files;
SQL> alter database datafile '/u01/oradata/wilson/wenchuan01.dbf' resize 40M;
移动数据文件(alter tablespace)
SQL> alter tablespace wenchuan offline;
$ mv wenchuan02.dbf ..
SQL> alter tablespace wenchuan rename datafile '/u01/oradata/wilson/wenchuan02.dbf'
2 to '/u01/oradata/wenchuan02.dbf';
SQL> alter tablespace wenchuan online;
移动数据文件(alter database)
SQL> shutdown immediate
$ mv wenchuan02.dbf wilson/
SQL> startup mount
SQL> alter database rename file '/u01/oradata/wenchuan02.dbf'
2 to '/u01/oradata/wilson/wenchuan02.dbf';
SQL> alter database open;
SQL> create tablespace wenchuan
2 datafile '/u01/oradata/wilson/wenchuan01.dbf' size 20M
3 extent management local uniform size 128k
4 segment space management auto;
$ cd [ORACLE_HOME]/rdbms/admin
Log into SQL*Plus as SYSTEM
SQL> @utlxplan
SQL> GREATE PUBLIC SYNONYM PLAN_TABLE FOR PLAN_TABLE;
SQL> GRANT ALL ON PLAN_TABLE TO PUBLIC;
SQL> quit
$ cd [ORACLE_HOME]/sqlplus/admin
Log into SQL*Plus as SYS or as SYSDBA
SQL> @plustrce
SQL> GRANT PLUSTRACE TO PUBLIC;
特定用户登录
SQL> set autot on stat
SQL> select count(*) from tb;
SQL> begin
2 for i in 1 .. 1000000
3 loop
4 insert into tb values(i, 'boobooke');
5 end loop
6 ;
7 commit;
8 end;
9 /
SQL> select max(undoblks / ((end_time - begin_time)*24*3600)) from v$undostat; 每秒需要最多的undo数据块
SQL> show user;
USER ? "SYS"
SQL> create tablespace assm datafile
2 '/u01/oradata/wilson/assm_1.dbf' size 100M
3 extent management local uniform size 128k
4 segment space management auto;
SQL> create tablespace mssm datafile
2 '/u01/oradata/wilson/mssm_1.dbf' size 100M
3 extent management local uniform size 128k
4 segment space management manual;
SQL> create user as1 identified by as1 default tablespace assm;
SQL> create user ms1 identified by ms1 default tablespace mssm;
SQL> grant connect, resource to as1;
SQL> grant connect, resource to ms1;
SQL> create global temporary table tmp_session on commit preserve rows
2 as select * from t where 1=0; 创建会话临时表
SQL> create global temporary table tmp_transaction on commit delete rows
2 as select * from t where 1=0; 创建事务临时表
SQL> insert into tmp_session select * from t;
SQL> insert into tmp_transaction select * from t;
SQL> alter table hr.employees
2 pctfree 30
3 pctused 50
4 storage (next 500k minextents 2 maxextents 100);
SQL> alter table hr.employees
2 move tablespace data1;
SQL> select dbms_metadata.get_ddl('TABLE','T') from dual; 查看完整的表结构
SQL> alter table t
2 set unused column name;
SQL> alter table orders allocate extent;
SQL> create index hr.employees_last_name_idx
2 on hr.employess(last_name)
3 pctfree 30
4 storage(initial 200k next 200k pctincrease 0 maxextents 50)
5 tablespace indx;
SQL> create bitmap index my_bit_indx on t(sex); 创建位图索引
SQL> alter index order_region_id_idx rebuild
2 tablespace indx02;
SQL> alter index my_bit_indx rebuild online; 联机重建索引
SQL> alter index my_bit_indx coalesce; 整理索引碎片
SQL> analyze index my_bit_indx validate structure; analyze index my_bit_indx validate structure offline;
SQL> select height,name,lf_rows,lf_blks,del_lf_rows from index_stats;
查看索引有没有被使用
SQL> alter index my_bit_indx monitoring usage;
SQL> select * from v$object_usage;
SQL> set autot on exp
SQL> set autot off
SQL> alter index my_bit_indx nomonitoring usage;
SQL> alter table t modify id not null;
SQL> alter table bonus
2 add constraint uq_emp_id unique(dept, emp_id)
3 using index tablespace indx
4 storage (initial 32k next 32k pctincrease 0);
SQL> select constraint_name, status, validated from user_constraints; (1,54节)
SQL> alter table t add primary key(id) deferrable;
SQL> alter table t disable primary key;
SQL> insert into t values(0, 'boobooke');
SQL> insert into t values(0, 'boobooke');
SQL> alter table t enable novalidate primary key; / alter table t enable novalidate constraint t_pk;
/ alter table t enable validate constraint t_pk;
SQL> set constraints all deferred;
SQL> @?/rdbms/admin/utlexpt1.sql
SQL> alter table t enable validate primary key exceptions into exceptions;
SQL> select rowid, id, name from t where rowid in (select row_id from exceptions);
SQL> @?/rdbms/admin/utlpwdmg 密码管理 (1,56节)
SQL> select * from session_privs; 查看本用户权限
SQL> create user u1 identified by u1 default tablespace mytbs quota unlimited on mytbs;
SQL> revoke create table from emi;
SQL> select * from session_roles;
SQL> select * from role_role_privs;
SQL> select * from role_sys_privs;
SQL> select * from role_tab_privs;
SQL> alter system set audit_trail=db scope=spfile;
SQL> shutdown immediate
SQL> startup
SQL> audit session by boobooke;
SQL> select username, timestamp, action_name from dba_audit_trail;
SQL> noaudit session by boobooke;
SQL> alter table emp nologging;
SQL> insert /*+ APPEND */ into emp
2 select * from t_employees;
SQL> commit;
SQL> create table emp
2 (empno int,
3 ename varchar2(20)
4 )
5 partition by hash(empno)
6 (partition part1,
7 partition part2
8 )
9 /
SQL> alter session enable parallel dml;
SQL> insert /*+ PARALLEL(hr.emp,2) */
2 into hr.employees
3 select * from hr.old_employees;
SQL> commit;
SQL> select * from nls_database_parameters; 查询字符集
SQL> show parameter nls_length_sematic
SQL> select id, dump(name, 1016) from tb;
SQL> ALTER SESSION SET NLS_LANGUAGE=Italian;
C:\> set NLS_LANG=American_America.ZHS16GBK
$ export NLS_LANG=American_America.ZHS16GBK
SQL> select * from nls_session_parameters;
SQL> select * from v$nls_valid_values;
C:\>tnsping WILSON 10
SQL> alter system set dispatchers='(PROTOCOL=TCP) (dispatchers=4) (SERVICE=wilson)';
SQL> select circuit,dispatcher,server,status,queue from v$circuit;
$ cat /dev/null > alert_wilson.log 清空文件
归档模式
把数据库改为归档日志模式
SQL> shutdown normal/immediate/transtractions
SQL> startup mount
SQL> alter database archivelog/noarchivelog;
SQL> alter database open;
SQL> shutdown immediate
到oradata下做全备
system set log_archive_start=true scope=spfile;
SQL> alter system set log_archive_max_processes=2;
SQL> show parameter log_archive_start
SQL> alter system archive log start to '/oradata/archive1';
SQL> archive log list
SQL> alter system archive log stop;
SQL> alter system archive log current; 手动归档
SQL> alter system set log_archive_dest_1="location=/u01/admin/wilson/archive" scope=both;
SQL> alter system set log_archive_format="wilson%t_%S_%r.arc" scope=spfile;
SQL> alter system switch logfile;
备份
SQL> select name, status from v$datafile;
SQL> select name from v$controlfile;
SQL> select member from v$logfile;
SQL> SELECT t.name tablespace, f.name datafile
2 FROM v$tablespace t, v$datafile f
3 WHERE t.ts# = f.ts#
4 ORDER BY t.name; 查询表空间里有哪些数据文件
热备 bbk4020
SQL> select file_name, tablespace_name from dba_data_files;
SQL> alter tablespace example begin backup;
SQL> !cp /u01/oradata/wilson/example01.dbf /tmp/hb
SQL> alter tablespace example end backup;
SQL> alter system archive log current;
SQL> alter system switch logfile; 可多做几次
SQL> select dbms_rowid.rowid_block_number(rowid) blk, name fruit; //1012
$ dd if=example01.dbf ibs=8192 skip=1011 count-2 | strings
SQL> select * from v$backup; bbk4020 p298
SQL> alter database [datafile 5] end backup; 备份时突然断电,再启动时处于mounted状态使用,中括号里可有可无
SQL> alter database open;
bbk4021
SQL> alter tablespace example read only;
SQL> alter tablespace example read write;
SQL> alter database backup controlfile to '/tmp/con/c1.ctl'; p303
SQL> alter database backup controlfile to trace as '/tmp/con/c2.sql';
sys_dba_segs utilis
$ dbv file=system01.dbf feedback=100 p306
pbbk4022
$ rman target sys/123456@WILSON nocatalog / $ rman target / nocatalog
RMAN> show all;
RMAN> configure default device type to sbt;
RMAN> configure default device type clear;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/ctl_%F';f
RMAN> list backup of database;
RMAN> list backup of datafile '/u01/oradata/wilson/system01.dbf';
RMAN> list copy of tablespace 'USERS';
RMAN> list backup of tablespace 'USERS';
pbbk4023
RMAN> report schema;
RMAN> backup datafile 4,5 format '/u01/backup/md_%U';
RMAN> backup datafile '/u01/oradata/wilson/users01.dbf' format '/u01/backup/df_%U';
RMAN> list backup;
RMAN> delete backupset 1,2;
RMAN> backup database [format '/u01/backup/md_%U']; pbbk4023
RMAN> backup tablespace USERS,EXAMPLE format '/u01/backup/ts_%U'; pbbk4024
RMAN> backup current controlfile;
RMAN> backup datafile 4 include current controlfile [format '...'];
RMAN> sql "alter database backup controlfile to ''/u01/backup/ctl_20100515.ctl''";
RMAN> backup spfile format '/u01/backup/sp_%U';
RMAN> backup archivelog all format '/u01/backup/ac_%U' delete all input;
RMAN> backup archivelog sequence between 99 and 199 thread 1 delete input;
RMAN> backup archivelog from time "sysdate-15" until time "sysdate-7";
pbbk4025
RMAN> backup database plus archivelog format '/u01/backup/db_%U';
RMAN> run {
2> allocate channel d1 device type disk maxpiecesize=100M;
3> backup database filesperset 3;
4> }
RMAN> run{
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> allocate channel c3 type disk;
5> backup incremental level=0
6> format '/u01/backup/p_%U'
7> (datafile 5 channel c1 tag='example')
8> (datafile 7 channel c2 tag='assm')
9> (datafile 4,6 channel c3 tag='other');
10> sql 'alter system archive log current';
11> }
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET; 设置并发度为3
RMAN> backup copies 2 datafile 5 format '/u01/b1/d_%U','/u01/b2/d_%U';
RMAN> copy datafile 5 to '/u01/backup/example20101515.dbf' tag='example';
RMAN> list copy;
RMAN> backup as copy datafile 5 format '/u01/backup/example20101515.dbf';
pbbk4026
RMAN> run {
2> allocate channel d1 type disk;
3> backup incremental level 0 database format '/u01/backup/10_%U';
4> }
select sid, sofar, totalwork from v$session_longops;
--差异增量
RMAN> run {
2> allocate channel d1 type disk;
3> backup incremental level 1 database format '/u01/backup/l1_%U';
4> }
--累积增量
RMAN> run {
2> allocate channel d1 type disk;
3> backup incremental level 1 cumulative database format '/u01/backup/lc1_%U';
4> }
pbbk4027
SQL> alter database enable block change tracking using file
2 '/u01/track.bin'; 10g以上可用
SQL> alter database disable block change tracking;
RMAN> backup incremental level 2 datafile 4 tag='wilsonram';
RMAN> list backup tag='wilsonram';
添加磁盘 bbk4029
# cd /dev
[root@xia dev]# fdisk sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-522, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522):
Using default value 522
Command (m for help): p
Disk sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
sdb1 1 522 4192933+ 83 Linux
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@xia dev]# mkfs.ext3 sdb1
[root@xia ~]# mkdir md
[root@xia ~]# mount /dev/sdb1 md (要自动挂载可修改/etc/fstab)
SQL> conn / as sysdba
Connected to an idle instance.
SQL> create pfile from spfile;
SQL> startup mount
SQL> select file#,name from v$datafile;
SQL> alter database rename file '/u01/oradata/wilson/system01.dbf' to 'xxx/system01.dbf';
SQL> select file#,name from v$tempfile;
SQL> select group#,member from v$logfile;
SQL> alter database open;
生成联机重做日志文件 p368
SQL> startup mount
SQL> recover database until cancel using backup controlfile;
cancel
SQL> alter database open resetlogs;
bbk4071
SQL> select * from v$recover_file;
no rows selected 说明数据库正常,没有文件损坏,不需要恢复
手工完全恢复 bbk4072
SQL> create tablespace app1 datafile '/u01/oradata/wilson/app1_01.dbf' size 100M
2 extent management local uniform segment space management auto;
SQL> select file#,ts#,name from v$datafile;
SQL> create user user1 identified by user1# default tablespace app1;
SQL> grant connect, resource to user1;
SQL> conn user1/user1#
SQL> shutdown immediate
SQL> set autorecovery off
SQL> recover datafile 1;
SQL> alter database open;
bbk4092 p395
SQL> select file#,checkpoint_change# from v$datafile; 从控制文件读
SQL> select file#,checkpoint_change# from v$datafile_header; 从数据文件头读
bbk4092
恢复控制文件
SQL> alter database backup controlfile to '/u01/ubackup/ctl.bin';
Database altered.
SQL> shutdown abort
ORACLE instance shut down.
$ cp /u01/ubackup/ctl.bin /u01/oradata/ORCL/controlfile/o1_mf_66f5g4on_.ctl
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1267044 bytes
Variable Size 100666012 bytes
Database Buffers 176160768 bytes
Redo Buffers 7118848 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open bbk4092
SQL> recover database using backup controlfile;
ORA-00279: change 709886 generated at 02/06/2011 21:22:28 needed for thread 1
ORA-00289: suggestion : /u01/achive/1_14_742408353.dbf
ORA-00280: change 709886 for thread 1 is in sequence #14
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/oradata/ORCL/onlinelog/o1_mf_1_6nwq51d5_.log
ORA-00310: archived log contains sequence 13; sequence 14 required
ORA-00334: archived log: '/u01/oradata/ORCL/onlinelog/o1_mf_1_6nwq51d5_.log'
SQL> recover database using backup controlfile;
ORA-00279: change 709886 generated at 02/06/2011 21:22:28 needed for thread 1
ORA-00289: suggestion : /u01/achive/1_14_742408353.dbf
ORA-00280: change 709886 for thread 1 is in sequence #14
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/oradata/ORCL/onlinelog/o1_mf_2_6nwq5572_.log
ORA-00283: recovery session canceled due to errors
ORA-01244: unnamed datafile(s) added to control file by media recovery
ORA-01110: data file 8: '/u01/oradata/ORCL/datafile/app3_01.dbf'
ORA-01112: media recovery not started
SQL> recover database using backup controlfile;
ORA-00283: recovery session canceled due to errors
ORA-01111: name for data file 8 is unknown - rename to correct file
ORA-01110: data file 8: '/u01/oracle/dbs/UNNAMED00008'
ORA-01157: cannot identify/lock data file 8 - see DBWR trace file
ORA-01111: name for data file 8 is unknown - rename to correct file
ORA-01110: data file 8: '/u01/oracle/dbs/UNNAMED00008'
SQL> col error for a18
SQL> select * from v$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- ------- ------------------ ---------- ------------
8 ONLINE ONLINE FILE MISSING 0
SQL> col name format a50
SQL> select file#,name from v$datafile;
FILE# NAME
---------- --------------------------------------------------
1 /u01/oradata/ORCL/datafile/o1_mf_system_66f5cpnh_.
dbf
2 /u01/oradata/ORCL/datafile/o1_mf_undotbs1_66f5cpv6
_.dbf
3 /u01/oradata/ORCL/datafile/o1_mf_sysaux_66f5cpo1_.
dbf
4 /u01/oradata/ORCL/datafile/o1_mf_users_66f5cpx9_.d
bf
FILE# NAME
---------- --------------------------------------------------
5 /u01/oradata/ORCL/datafile/perfstat_01.dbf
6 /u01/oradata/ORCL/datafile/app1_01.dbf
7 /u01/oradata/ORCL/datafile/app02_01.dbf
8 /u01/oracle/dbs/UNNAMED00008
8 rows selected.
SQL> alter database rename file '/u01/oracle/dbs/UNNAMED00008' to '/u01/oradata/ORCL/datafile/app3_01.dbf';
Database altered.
SQL> select file#,name from v$datafile;
FILE# NAME
---------- --------------------------------------------------
1 /u01/oradata/ORCL/datafile/o1_mf_system_66f5cpnh_.
dbf
2 /u01/oradata/ORCL/datafile/o1_mf_undotbs1_66f5cpv6
_.dbf
3 /u01/oradata/ORCL/datafile/o1_mf_sysaux_66f5cpo1_.
dbf
4 /u01/oradata/ORCL/datafile/o1_mf_users_66f5cpx9_.d
bf
FILE# NAME
---------- --------------------------------------------------
5 /u01/oradata/ORCL/datafile/perfstat_01.dbf
6 /u01/oradata/ORCL/datafile/app1_01.dbf
7 /u01/oradata/ORCL/datafile/app02_01.dbf
8 /u01/oradata/ORCL/datafile/app3_01.dbf
8 rows selected.
SQL> recover database using backup controlfile until cancel; bbk4092
ORA-00279: change 711258 generated at 02/06/2011 21:51:50 needed for thread 1
ORA-00289: suggestion : /u01/achive/1_14_742408353.dbf
ORA-00280: change 711258 for thread 1 is in sequence #14
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/oradata/ORCL/onlinelog/o1_mf_1_6nwq51d5_.log
ORA-00310: archived log contains sequence 13; sequence 14 required
ORA-00334: archived log: '/u01/oradata/ORCL/onlinelog/o1_mf_1_6nwq51d5_.log'
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/oradata/ORCL/datafile/o1_mf_system_66f5cpnh_.dbf'
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 711258 generated at 02/06/2011 21:51:50 needed for thread 1
ORA-00289: suggestion : /u01/achive/1_14_742408353.dbf
ORA-00280: change 711258 for thread 1 is in sequence #14
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/oradata/ORCL/onlinelog/o1_mf_2_6nwq5572_.log
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
RMAN恢复 bbk4098
C:/> rman target xxx/xxxx@ip:prot/sid
RMAN> list backup;
RMAN> backup database format '/u01/backup/wb_%U';
RMAN> sql 'alter system archive log current';
p410
RMAN> run{
set newname for datafile 1 to '/<newdir>/system01.dbf';
restore database;
switch datafile all;
recover database;
alter database open; }
p412
RMAN> run{
sql “alter database datafile 6 offline immediate”;
restore datafile 6;
recover datafile 6;
sql “alter database datafile 6 online”;
}
bbk4314 p421
SQL> recover database using backup controlfile until cancel;
bbk4320 p453
RMAN> RUN {
ALLOCATE CHANNEL c1 TYPE DISK;
ALLOCATE CHANNEL c2 TYPE DISK;
SET UNTIL TIME "to_date('2010-05-19:09:20:42','YYYY-MM-DD:HH24:MI:SS')";
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS; }
to_date('2010-05-19:09:20:42','YYYY-MM-DD:HH24:MI:SS')
bbk4444
导入导出
SQL> grant exp_full_database,imp_full_database to user;
bbk4445
c:\> chcp
SQL> select * from nls_database_parameters;
c:\> SET NLS_LANG=American_America.AL32UTF8 (NLS_LANGUAGE _ NLS_TERRITORY .NLS_CHARACTERSET)
c:\> exp user/passwd parfile=p.txt
c:\> imp user/passwd show=y file=XXX.dmp
bbk4446
c:\> exp user/passwd parfile=p.txt direct=y 直接导出较快,buffer不起作用
锁定SGA不换页
SQL> alter system set lock_sga=true scope=spfile;
c:\>lsnrctl
LSNRCTL> help