6.启动例程和打开数据库的步骤
Nomount:启动instance ,读取 参数文件,分配SGA,打开background trace file
Mount:装载database ,打开control file
Open:打开数据库。打开data file 和redo log file
当有上面一个状态变为另一个状态时候,需要alter database
例如:SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 629145600 bytes
Fixed Size 1220964 bytes
Variable Size 331353756 bytes
Database Buffers 293601280 bytes
Redo Buffers 2969600 bytes
SQL> alter database mount
2 ;
Database altered.
第四章 建立数据库
这一章主要讲解数据库的创建,数据库用dbca创建比较简单,不再总结。
1. 命令删除数据库
首先把数据库启动到mount状态,记住必须用restrict模式
Startup mount restrict
Dorp database
第五章 数据字典和动态性能视图
1.三者的区别
Dba_
All_
User_
2.数据字典
SQL> select * from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------------
ORACLE.REGRESS.RDBMS.DEV.US.ORACLE.COM
SQL> select user from dual;
USER
------------------------------
SYS
SQL> select sysdate from dual;
SYSDATE
----------
2010-06-25
3.常用动态性能视图:
V$fix_table
V$instance
V$SGA
V$sgainfo(更为详细)
V$parameter
V$version
V$option
V$session
V$process
V$bgprocess
V$database
V$controlfile
V$datafiel
V$bgdatafile
V$logfile(日志成员)
V$log(日志组)
V$thread
V$lock
V$locked_object
V$rollname(处于online状态的undo段)
V$rollstat(undo段统计信息)
V$tablespace
V$tempfile
第六章 管理控制文件
1. 多元化控制文件的方法
可以使用pfile和spfile 两种方法
修改参数-关闭数据库-复制控制文件-启动数据库
其中修改参数pfile手工修改
Spfile动态修改alter system set control_files=’ /u01/oradata/oracle/control01.ctl’,’ /u01/oradata/oracle/control02.ctl’ scope=spfile;
复制控制文件的方法:
Windows操作系统:host copy d:\demo\control01.ctl e:\demo\control02.ctl
Linux 操作系统:cp /u01/oradata/oracle/control01.ctl /u01/oradata/control01.ctl
2. 查看控制文件的详细信息视图:v$control_record_section
3. 删除控制文件:动态alter system
第七章 管理重做日志
1. 增加日志组和日志成员
增加日志组:alter database add logfile
'/u01/oradata/oracle/redo04.log'
Size 10m
或者:
SQL> alter database add logfile group 4
2 '/u01/oradata/oracle/redo04.log'
3 size 10m;
增加日志成员:alter database add logfile member
SQL> alter database add logfile member
2 '/u01/oradata/oracle/redo02_b.log' to group 2;
Database altered.
增加日志组前先用查询此日志组的状态SQL> select * from V$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- ----------
1 1 4 52428800 1 YES ACTIVE
1923649 2010-06-27
2 1 2 52428800 1 YES INACTIVE
1896411 2010-06-25
3 1 3 52428800 1 YES INACTIVE
1899938 2010-06-25
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- ----------
4 1 5 10485760 1 NO CURRENT
1928911 2010-06-27
学会利用alter system switch logfile
2. 删除日志成员和日志组
删除日志组:首先查询日志成员所在的日志组的状态,然后根据情况使用alter system switch logfile;
SQL> alter database drop logfile member
2 '/u01/oradata/oracle/redo02_b.log';
Database altered.
删除日志组:状态必须是inactive unused
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- ----------
1 1 8 52428800 1 NO CURRENT
1949747 2010-06-27
2 1 6 52428800 1 YES INACTIVE
1929667 2010-06-27
3 1 7 52428800 1 YES INACTIVE
1929679 2010-06-27
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- ----------
4 1 5 10485760 1 YES INACTIVE
1928911 2010-06-27
SQL> alter database drop logfile group 3;
Database altered.
3.清除重做日志组
Clear之后状态变为unused,清楚之后,生成新的日志组成员
SQL> alter database clear logfile group 3;
Database altered.
4.更改重做日志的名称或位置
首先要处于非current状态,
复制到新的位置[oracle@oracle ~]$ cp /u01/oradata/oracle/redo02.log /u01/oradata/redo02.log
修改位置SQL> alter database rename file '/u01/oradata/oracle/redo02.log'
2 to '/u01/oradata/redo02.log';
Database altered.
SQL> select * from v$logfile;
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_
---
3 ONLINE
/u01/oradata/oracle/redo03.log
NO
1 ONLINE
/u01/oradata/oracle/redo01.log
NO
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_
---
4 ONLINE
/u01/oradata/oracle/redo04.log
NO
2 ONLINE
/u01/oradata/redo02.log
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_
---
NO
第八章 管理归档日志
1.Archive log是处于非活动redo log的备份。
2.改变归档状态
首先查询此刻归档状态:SQL> select log_mode from v$database;
LOG_MODE
------------
NOARCHIVELOG
或者:archive log list
然后把数据库至于mount状态
Alter database archivelog/noarchivelog
3. 改变log_archive_format
SQL> alter system set log_archive_format='%s_%t_%r'
2 scope=spfile;
System altered.
4. 改变归档日志的位置
alter system set log_archive_ dest=e’/u0/oradata/arch’
使用log_archive_dest_n不能与log_archive_dest,log_archive_duplex_dest同时使用,使用前先把先把这两个参数:alter system set log_atchive_dest=’ ‘;
5. archive log list
6. select name,log_mode from v$database;
7. v$archive_log
8. v$archived_dest
9. v$loglist
10. v$archive_processes
第九章 管理表空间和数据文件
我在这里只写几个比较常用的表空间创建方法
1.创建自动扩展的表空间
SQL> create tablespace tab01
2 datafile '/u01/tab01.dbf' size 10m
3 extent management local autoallocate;
Tablespace created.
2.创建等量扩展的表空间
SQL> create tablespace tab02
2 datafile '/u01/tab02.dbf' size 10m
3 extent management local uniform. size 1m;
Tablespace created.
3.创建临时表空间
SQL> create temporary tablespace temp01
2 tempfile '/u01/temp01.dbf' size 2m;
Tablespace created.
创建temporay tablespace的时候出现了问题:
SQL> createtemporary tablespacetemp01
2 tempfile'/u01/temp01.dbf' size 2m
3 extent management local autoallocate;
extent management local autoallocate
*
ERROR at line 3:
ORA-25139:invalid option for CREATE TEMPORARY TABLESPACE
SQL> create temporary tablespace temp02
2 tempfile '/u01/temp02.dbf' size 2m
3 extent management local uniform. size 1m;
Tablespace created.
表明创建temporary tablespace 的时候必须 uniform
SQL> create temporary tablespace temp03
2 tempfile '/u01/temp03.dbf' size 2m
3 segment space management auto;
segment space management auto
*
ERROR at line 3:
ORA-30573: AUTO segment space management not valid for this type of tablespace
SQL> create temporary tablespace temp03
2 tempfile '/u01/temp03.dbf' size 2m
3 segment space management manual;
Tablespace created.
表明temporary tablespace 的时候必须segment space management manual;
4.创建undo tablespace
SQL> create undo tablespace undo01
2 datafile '/u01/undo.dbf' size 1m;
Tablespace created.
5.创建bigfile tablespace
什么是bigfile tablespace和smallfile?
BigFile创建的TableSpace可以达到2的32次方个blocks,只能创建一个Datafile。 而SmallFile最大到2的22次方,SmallFile最多可以创建1022个Datafile,总和稍少于BigFile。
Bigfile tablespaces are intended for very large databases. When a very large database has thousands of read/write datafiles, operations that must update the datafile headers, such as checkpoints, can take
a relatively long time. If you reduce the number of datafiles, these operations can complete faster.Smallfile tablespace
is the new name for the old Oracle tablespace datafile option. With a smallfile tablespace, you can have multiple datafiles for a tablespace.(引自administration I)
SQL> createbigfile tablespacebfspace
2 datafile '/u01/bfspace.dbf' size 2m;
Tablespace created.
简单的把几种命令创建表空间的方法写出来了。当然还有其他方法,比如用TOAD。
6.维护表空间
改变表空间的可用性:alter tablespace tablespacename offline/online
改变数据文件的可用性:alter database datafile datafilename offile/online
当出现数据文件损坏,数据库无法开启的时候,应该先offline损坏的数据文件,然后开启数据库,修复数据文件
在noarchivelog模式下,offline drop
改变读写状态:alter tablespace tablespacename read only
Alter tablespace tablespacename read write
改变表空间名称:alter tablespace tablespacename rename to anothertablsespacename;
设置默认的表空间:alter database default (temporary) tablespace tbpsname;
删除表空间: drop tablespace tbspname including contents (and datafiles)
扩展表空间:以前用的方法都是利用TOAD,现在学习一下用命令行的方式
Alter tablespace tbsname add datafile ‘/u01/….’ Size 10m;
Alter database datafile ‘/u01/..’ resize 10m;
Alter database datafile ‘/u01/..’ autoextend on next 10m maxzsize 1g
移动数据文件:
Open状态:必须使用alter tablespace
首先offline –move-rename-online
Mount状态:alter database
举例:
SQL> select * from v$tablespace;
TS# NAME INC BIG FLA ENC
---------- ------------------------------ --- --- --- ---
0 SYSTEM YES NO YES
2 SYSAUX YES NO YES
4 USERS YES NO YES
3 TEMP NO NO YES
6 DATA YES NO YES
8 UNDOTBS3 YES NO YES
6 rows selected.
SQL> alter tablespace data online;
Tablespace altered.
SQL> select *from dba_data_files;/*查询数据文件路径*/
[oracle@oracle ~]$ cp /u01/oracle/dbs/d:data.ora /u01/oracle/d:data.ora
SQL> alter tablespace data
2 rename datafile '/u01/oracle/dbs/d:data.ora'
3 to '/u01/oracle/d:data.ora';
Tablespace altered.
SQL> alter tablespace data online;
Tablespace altered.
1. 显示信息
Dba_tablespaces
Dba_data_files
V$tablespace
V$datafile
Dba_tabalespace_groups
Dba_temp_files
V$tempfile
第四章 管理undo表空间
例程恢复都是由oracle server自动恢复的
9i之前用undo segment 管理undo数据,9i之后用undo表空间
管理undo表空间和管理其他表空间有很多相似之处。
怎么确定是那种方式undo数据管理?
Show parameter undo_management;
SQL> show parameter undo_management;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
AUTO:为利用undo表空间管理
Manual:为利用undo segment 管理
Undo表空间的作用:一致性!
视图:v$undostat
第十一章 管理对象空间
1.Block是数据文件上执行I/O的最小单位,extent是进行空间分配的最小单位。
2.段视图:dba_segments
第十二章 管理用户
Dba_users,all_users,user_users,要明白三者的区别
第十三章 管理权限
1.系统权限是指用户可以执行某个操作的权限,而对象权限是对特定的方案对象进行操作的权限.它们的最大区别在于系统权限不属于某个具体的方案对象.
2.Grant ** to (with admin option);
Revoke ** from
系统权限不会被连级收回
1. 管理对象权限
Grant alter on emp to
Revoke ** on ** from **
对象权限会被级联收回
第十四章 管理角色
创建角色:Create role ** not indentified (indentified by **)
数据字典:Dba_roles
第十五章 管理profile
Dba_profiles
第十六章 审计
startup force=shutdown abort+startup
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22821701/viewspace-666503/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22821701/viewspace-666503/