10gocm-)session4-)数据仓库
一 当有数据文件被误删除时如何恢复 RMAN规划 host target库 catalog库 ocm01 ocmdb ocm02 ocmdb02 模拟ocmdb库system01.dbf 数据文件丢失,利用catalogue库omcdb02进行RMAN恢复。 构造场景 shutdown immediate rm -f /u01/oracle/oradata/ocmdb/disk1/syste
一 当有数据文件被误删除时如何恢复
host | target库 | catalog库 |
ocm01 | ocmdb | |
ocm02 | ocmdb02 |
模拟ocmdb库system01.dbf 数据文件丢失,利用catalogue库omcdb02进行RMAN恢复。
构造场景shutdown immediate
rm -f /u01/oracle/oradata/ocmdb/disk1/system01.dbf
sqlplus / as sysdba
startup
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/oracle/oradata/ocmdb/disk1/system01.dbf'
alert日志中同样记录了报错信息(现在数据库处于异常关闭状态),从告警日志中就可以知道是system文件没有了 --alert日志位置:/u01/oracle/admin/ocmdb/bdump/alert_ocmdb.log
将数据库启动到mount状态,才能restore and recover 恢复
shutdown abort
startup mount
exit
登录RMAN
rman target sys/sys@ocmdb1521 catalog catalog_admin/catalog_admin@ocmdb021521
用原来的RMAN备份来还原和恢复
restore datafile 1;
recover datafile 1;
alter database open;
select file_name,tablespace_name,status from dba_data_files where tablespace_name='SYSTEM';
二 物化视图
host | 基表&日志 | 物化视图 | dblink |
ocm01 | mv_t | dblink_to_ocm02 | |
ocm02 | t_mv_ocm02,MLOG$_T_MV_OCM02 |
物化视图:执行sql并保留结果,直接放在数据文件中,不放在内存中方便重用【空间换时间】
场合:同步数据,过滤数据并两次利用
1.要求创建跨库物化视图并可手动更新
官方文档:PL/SQL Packages and Types Reference -> 61 DBMS_MVIEW
基表和物化视图不在同一个库上,基表和日志在ocm02上,物化视图在ocm01上,在ocm01上可手动刷新物化视图
ocm02
create user mv_ocm02 identified by mv_ocm02 ;grant connect,resource to mv_ocm02 ;
conn mv_ocm02 /mv_ocm02
create table t_mv_ocm02(a varchar2(10));
insert into t values ('test01');
commit;
select * from t_mv_ocm02;
创建物化视图日志,基表在哪个库,日志就在哪个库,用于记录基表所有变化,实时刷新物化视图,完全刷新不需要物化视图日志,快速刷新需要物化视图日志create materialized view log on t with rowid; 基于rowid变化记录到日志中 --创建MLOG$_T_MV_OCM02对象
ocm01
创建dblinksqlplus / as sysdba@ocmdb
create public database link dblink_to_ocm02 connect to mv_ocm02 identified by mv_ocm02 using 'ocmdb021521';
注:global_names参数为FALSE 才允许DB link名字与我远程连接实例名不一致
create user mv_ocm01 identified by mv_ocm01 ;
grant dba to mv_ocm01 ;
conn mv_ocm01 /mv_ocm01
创建跨库可刷新物化视图
create materialized view mv_t refresh fast with rowid as select * from t_mv_ocm02@dblink_to_ocm02;
sqlplus mv_ocm02 /mv_ocm02 @ocmdb021521insert into t values ('test02');
commit;
select * from t_mv_ocm02;
sqlplus mv_ocm01 /mv_ocm01 @ocmdb
select * from mv_t;
快速刷新方法:增量刷新 或 完全刷新方法:全表刷新exec dbms_mview.refresh('mv_t','f'); 手动刷新物化视图
exec dbms_mview.refresh('mv_t','c');
select * from mv_t;
2.要求创建物化视图具有自动快速刷新功能sqlplus mv_ocm01 /mv_ocm01 @ocmdb
注:grant connect,resource,create materialized view to mv_ocm01 ; 如果是普通用户需要授予创建物化视图权限
drop table t1 purge;
create table t1 (x int,y int,z int);
insert into t1 values (1,2,3);
insert into t1 values (4,5,6);
commit;
select * from t1;
create materialized view log on t1 with sequence,rowid (x,y,z) including new values;
我们只看x和y列信息
drop materialized view mv_t1;
create materialized view mv_t1 build immediate refresh with rowid fast on commit enable query rewrite as select x,y from t1;
参数说明:
build immediate:创建物化视图时,立即刷新基表
fast on commit:支持基于commit动作的自动刷新
enable query rewrite:启动查询重写功能
refresh with rowid:物化视图默认是基于主键PK方式来刷新的,由于基表没有主键,因此我们基于ROWID刷新
select * from mv_t1;
验证物化视图是否随记录增加而更新
insert into t1 values (7,8,9);
select * from t1;
select * from mv_t1; mv_t1随记录增加而木有刷新,必须commit之后才触发物化视图刷新
commit;
select * from mv_t1;
delete from t1 where x=1;
select * from t1;
commit;
select * from mv_t1;
三 外部表
官方文档:Administrator’s Guide -> 15 Managing Tables -> Managing External TablesUtilities->Part III External Tables –> 14 The ORACLE_DATAPUMP Access Driver
外部表:把数据保存在操作系统层面上,并不保存在表空间上,即可以把数据写入外部表又可以读取外部表到数据库(只读到内存里)。外部表就是操作系统上的一个二进制文件不是纯文本文件。可用strings查看
场合:导出的数据可用于二次开发。数据迁移
要求使用oracle数据泵导出外部表并跨库加载
过程:ocm01卸载数据,传输到ocm02加载数据
步骤 | ocm01 | ocm02 | 说明 |
1 | 创建dir_dmp | 位置:ocm01:/home/oracle | |
2 | 导出t2_part1.dat,t2_part2.dat到dir_dmp | ||
3 | 创建dir_dmp | 位置:ocm02:/home/oracle | |
4 | 拷贝t2_part1.dat,t2_part2.dat到dir_dmp | scp把文件从ocm01拷贝到ocm02 | |
5 | 加载到数据库 |
创建directory
sqlplus / as sysdba@ocmdb
create user ext identified by ext;
grant dba to ext;
conn ext/ext
create directory dir_dmp as '/home/oracle';
grant read,write on directory dir_dmp to public; 授予读/写权限给目录对象,把目录对象给所有用户
创建外部表,使用数据泵工具卸载数据,使用2个cup并行卸载,加快速度
create table t2
organization external
(type oracle_datapump
default directory dir_dmp
location ('t2_part1.dat','t2_part2.dat')
)
parallel 2
as
select owner,object_id,object_name from dba_objects where owner='SYSTEM';
strings命令可以读取卸载得到的二进制文件内容
strings t2_part1.dat
在ocm02创建外部表t3读取t2_part1.dat和t2_part2.datscp t2_part1.dat t2_part2.dat ocm02:/home/oracle
sqlplus / as sysdba@ocmdb02
create user ext identified by ext;
grant dba to ext;
conn ext/ext
create directory dir_dmp as '/home/oracle';
grant read,write on directory dir_dmp to public;
加载数据到t3
create table t3 (owner varchar2(100),object_id varchar2(100),object_name varchar2(100))
organization external
(type oracle_datapump
default directory dir_dmp
location ('t2_part1.dat','t2_part2.dat'));
select count(*) from t3;
到此我们的外部表方式数据迁移完成。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

DDREASE is a tool for recovering data from file or block devices such as hard drives, SSDs, RAM disks, CDs, DVDs and USB storage devices. It copies data from one block device to another, leaving corrupted data blocks behind and moving only good data blocks. ddreasue is a powerful recovery tool that is fully automated as it does not require any interference during recovery operations. Additionally, thanks to the ddasue map file, it can be stopped and resumed at any time. Other key features of DDREASE are as follows: It does not overwrite recovered data but fills the gaps in case of iterative recovery. However, it can be truncated if the tool is instructed to do so explicitly. Recover data from multiple files or blocks to a single

0.What does this article do? We propose DepthFM: a versatile and fast state-of-the-art generative monocular depth estimation model. In addition to traditional depth estimation tasks, DepthFM also demonstrates state-of-the-art capabilities in downstream tasks such as depth inpainting. DepthFM is efficient and can synthesize depth maps within a few inference steps. Let’s read about this work together ~ 1. Paper information title: DepthFM: FastMonocularDepthEstimationwithFlowMatching Author: MingGui, JohannesS.Fischer, UlrichPrestel, PingchuanMa, Dmytr

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

Quark Netdisk and Baidu Netdisk are currently the most commonly used Netdisk software for storing files. If you want to save the files in Quark Netdisk to Baidu Netdisk, how do you do it? In this issue, the editor has compiled the tutorial steps for transferring files from Quark Network Disk computer to Baidu Network Disk. Let’s take a look at how to operate it. How to save Quark network disk files to Baidu network disk? To transfer files from Quark Network Disk to Baidu Network Disk, you first need to download the required files from Quark Network Disk, then select the target folder in the Baidu Network Disk client and open it. Then, drag and drop the files downloaded from Quark Cloud Disk into the folder opened by the Baidu Cloud Disk client, or use the upload function to add the files to Baidu Cloud Disk. Make sure to check whether the file was successfully transferred in Baidu Cloud Disk after the upload is completed. That's it

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

Recently, many netizens have asked the editor, what is the file hiberfil.sys? Can hiberfil.sys take up a lot of C drive space and be deleted? The editor can tell you that the hiberfil.sys file can be deleted. Let’s take a look at the details below. hiberfil.sys is a hidden file in the Windows system and also a system hibernation file. It is usually stored in the root directory of the C drive, and its size is equivalent to the size of the system's installed memory. This file is used when the computer is hibernated and contains the memory data of the current system so that it can be quickly restored to the previous state during recovery. Since its size is equal to the memory capacity, it may take up a larger amount of hard drive space. hiber
