设为首页 收藏本站
查看: 816|回复: 0

[经验分享] Oracle_052_lesson_p7

[复制链接]

尚未签到

发表于 2018-9-23 10:26:55 | 显示全部楼层 |阅读模式
Managing Database Storage Structures 管理DB存储架构
  you should be able to:
  1、Describe the storage of table row data in blocks
  2、Create and manage tablespaces
  3、Obtain tablespace information
  desc  dba_segments;
  desc  dba_extents;
  例 循环插入:
  declare
  begin
  for  i  in  1..100 loop
  insert  into  hr.emp  select *  from  hr.employess
  end  loop
  end
  /
  alter  system  checkpoint;  提交内存数据写入磁盘;
DSC0000.jpg

  创建表空间
  redo :执行的操作语句
  undo :原始数据,回滚用
  conn  hr/hr;
  select  *  from  session_privs;
  show parameter  undo;
DSC0001.jpg

DSC0002.jpg

DSC0003.jpg

DSC0004.jpg

DSC0005.jpg

  注:离线offline  mode  有三种:  normal  、temporary、immediate
  oracle表空间offline的三种方式区别
一 offline 表空间注意事项
  1 不能离线如下表空间
  system
  undo tablespace
  temporary tablespace
  2 考虑下离线表空间对某些用户是否有影响,比如某个用户的默认表空间为你要离线的表空间。

  二>  normal:
  A tablespace can be taken offline normally if no error conditions exist
  for any of the datafiles of the tablespace. No datafile in the tablespace
  can be currently offline as the result of a write error. When you specify
  OFFLINE NORMAL, the database takes a checkpoint for all datafiles of the
  tablespace as it takes them offline. NORMAL is the default
  以上说明:
  1 normal 是offline的默认方式
  2 normal 对表空间的所有数据文件执行检查点操作,online表空间时不需要介质恢复。
  3 normal 方式离线表空间时,不应该有写错误,表空间所有文件应该online状态。
  temporary:
  A tablespace can be taken offline temporarily, even if there are
  error conditions for one or more files of the tablespace. When
  you specify OFFLINE TEMPORARY, the database takes offline the
  datafiles that are not already offline, checkpointing them as it
  does so.
  If no files are offline, but you use the temporary clause, media
  recovery is not required to bring the tablespace back online.
  However, if one or more files of the tablespace are offline
  because of write errors, and you take the tablespace offline
  temporarily, the tablespace requires recovery before you can
  bring it back online.
以上说明:
  1 offline temporary 表空间时,如果表空间中没有offline的数据文件,则online该表空间时不需要介质恢复。
  2 offline temporary 表空间时,不会对已经offline的数据文件执行检查点操作,仅仅对online的数据文件执行检查点操作
  3 offline temporary 表空间时,对于离线表空间之前已经offline的数据文件,则online该表空间时,offline数据文件需要介质恢复。
immediate:
  A tablespace can be taken offline immediately, without the
  database taking a checkpoint on any of the datafiles. When you
  specify OFFLINE IMMEDIATE, media recovery for the tablespace is
  required before the tablespace can be brought online. You
  cannot take a tablespace offline immediately if the database is
  running in NOARCHIVELOG mode.
  以上说明三点:
  1 offline immediate  不会对表空间的任何文件执行检查点操作。
  2 online 表空间时需要对所有数据文件进行 media recovery
  3 offline immediate 需要数据库日志模式为归档
  注意事项
  如果必须离线表空间,推荐使用offline normal 方式离线该表空间,因为该表空间online时不需要执行介质恢复。
  三 实验
  1 测试offline temporary
  查询系统当前表空间以及相应的数据文件
  SQL> select a.name as tablespace,b.file#,b.status,b.name as datafile from v$tablespace a,v$datafile b where a.ts#=b.ts#;
  TABLESPACE                          FILE# STATUS  DATAFILE
  SYSTEM                                  1 SYSTEM  /oracle/CRM2/CRM/system01.dbf
  SYSAUX                                  3 ONLINE  /oracle/CRM2/CRM/sysaux01.dbf
  USERS                                   4 ONLINE  /oracle/CRM2/CRM/users01.dbf
  UNDOTBS2                                6 ONLINE  /oracle/CRM2/CRM/undotbs2.dbf
  ZX                                      5 ONLINE  /oracle/CRM2/CRM/zx1.dbf
  ZX                                      2 ONLINE  /oracle/CRM2/CRM/zx2.dbf

  SQL>>
  Database>  不能用offline normal正常offline 因为表空间zx数据文件2已经offline状态

  SQL>>  alter tablespace zx offline
  *
  ERROR at line 1:
  ORA-01191: file 2 is already offline - cannot do a normal offline
  ORA-01110: data file 2: '/oracle/CRM2/CRM/zx2.dbf'
  用offline temporary 离线

  SQL>>
  Tablespace>
  SQL>>  alter tablespace zx online
  *
  ERROR at line 1:
  ORA-01113: file 2 needs media recovery
  ORA-01110: data file 2: '/oracle/CRM2/CRM/zx2.dbf'
  SQL> recover datafile 2;
  Media recovery complete.
  使zx表空间online

  SQL>>
  Tablespace>  2 测试offline immediate
  查询当前表空间及其数据文件。
  SQL> select a.name as tablespace,b.file#,b.status,b.name as datafile from v$tablespace a,v$datafile b where a.ts#=b.ts#;
  TABLESPACE                          FILE# STATUS  DATAFILE
  SYSTEM                                  1 SYSTEM  /oracle/CRM2/CRM/system01.dbf
  SYSAUX                                  3 ONLINE  /oracle/CRM2/CRM/sysaux01.dbf
  USERS                                   4 ONLINE  /oracle/CRM2/CRM/users01.dbf
  UNDOTBS2                                6 ONLINE  /oracle/CRM2/CRM/undotbs2.dbf
  ZX                                      5 ONLINE  /oracle/CRM2/CRM/zx1.dbf
  ZX                                      2 ONLINE  /oracle/CRM2/CRM/zx2.dbf

  SQL>>
  Tablespace>
  SQL>>  alter tablespace zx online
  *
  ERROR at line 1:
  ORA-01113: file 2 needs media recovery
  ORA-01110: data file 2: '/oracle/CRM2/CRM/zx2.dbf'
  SQL> recover datafile 2;
  Media recovery complete.

  SQL>>  alter tablespace zx online
  *
  ERROR at line 1:
  ORA-01113: file 5 needs media recovery
  ORA-01110: data file 5: '/oracle/CRM2/CRM/zx1.dbf'
  SQL> recover datafile 5;
  Media recovery complete.

  SQL>>
  Tablespace>
DSC0006.jpg

DSC0007.jpg

DSC0008.jpg

  例:
  drop  tablespace  test;
  create  table  tt1  tablespace  test   as  select  *  from  hr.regions;
  删表空间: drop   tablespace  test1  include  contents   and  datafiles;
  select  tablespace_name, status  from  dba_tablespaces;
DSC0009.jpg

  OMF->指定文件路径
  SQL>select  member  from v$logfile;
  SQL>show  parameter  db_create;
DSC00010.jpg



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-600177-1-1.html 上篇帖子: Oracle_052_lesson_p6 下篇帖子: Oracle_052_lesson_p9
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表