search
HomeDatabaseMysql TutorialOracle数据库快照的使用

Oracle数据库快照的使用

正在看的ORACLE教程是:Oracle数据库快照的使用。oracle数据库的快照是一个表,它包含有对一个本地或远程数据库上一个或多个表或视图的查询的结果。正因为快照是一个主表的查询子集,使用快照可以加快数据的查询速度;在保持不同数据库中的两个表的同步中,利用快照刷新,数据的更新性能也会有很大的改善。

  下面以我在开发襄樊市电信局170话费催缴系统中使用快照加快查询速度的实现过程为例来说明快照的使用方法:

  170话费催缴系统是一个向用户电话播放催缴话费提示音的系统。用户的欠费金额存放在rs6000小型机sffw用户下的表yh_qfcx中(yh_qfcx表是一个随用户缴费情况动态变化的欠费记录表),而催缴系统的数据按要求存放在另外一台xf170服务器dmtcx用户下,为在dmtcx用户下使用sffw用户下表yh_qfcx中的部分数据,我在dmtcx用户下建立了yh_qfcx的快照S_yh_qfcx,以加快查询速度。

  具体步骤如下:

  一、在sffw用户下建立表yh_qfcx的快照日志;

  只有先建立表yh_qfcx的快照日志,才能在快照中执行快速刷新。

  Create snapshot log on yh_qfcx;

  二、在dmtcx用户下建立到sffw用户的数据库链link_sf;

  建立了到sffw用户的数据库链后才能从sffw用户下的表yh_qfcx中获取数据。

  Create database link link_sf

  Connect to sffw identified by xxxxxxx using 'rs6000';

  三、在dmtcx用户下建立快照s_yh_qfcx;

  Create snapshot s_yh_qfcx as

  Select yhh,qf6+qf5+qf4+qf3+qf2+qf1+qf qfje

  From yh_qfcx@link_sf

  Where tjbz='K' and bz6+bz5+bz4+bz3+bz2+bz1+bz>0;

  四、根据需要修改快照刷新的间隔时间;

  dmtcx用户下的快照s_yh_qfcx为了与sffw用户下的主表yh_qfcx保持同步,需要不断刷新快照。只有设定了快照的刷新间隔时间,oracle才会自动刷新该快照。

  快照的刷新有两种方式:快速刷新和完全刷新。快速刷新需要快照的主表先有快照日志存在;完全刷新时oracle执行快照查询,将结果放入快照。快速刷新比完全刷新快,因为快速刷新将主数据库的数据经网络发送到快照的数据少,仅需传送主表中修改过的数据,而完全刷新要传送快照查询的全部结果。

  Alter snapshot s_yh_qfcx refresh fast

  Start with sysdate+1/1440 next sysdate+1/144;

  {此SQL语句的意思为:设定oracle自动在1分钟

  (1/24*60)后进行第一次快速刷新,以后每隔10分钟

  (10/24*60)快速刷新一次。}

  Alter snapshot s_yh_qfcx refresh complete

  Start with sysdate+1/2880 next sysdate+1;

  {此SQL语句的意思为:设定oracle自动在30钞

  (30/24*60*60)后进行第一次完全刷新,

  以后每隔1天完全刷新一次。}

  说明:

  1、因为快照刷新是服务器自动完成的,所以要保证oracle数据库启动了快照刷新进程。查看oracle数据库是否启动了快照刷新进程,可以以数据库sys身份查看视图V_$SYSTEM_PARAMETER中的参数snapshot_refresh_processes的值是否为1,如果不为1,则快照刷新进程未启动。

  2、启动快照刷新进程的方法为:修改oracle数据库的初始化文件initorcl.ora,将其中的snapshot_refresh_processes参数的值改由0改为1,然后重新启动oracle数据即可。

  3、需要说明的是:建立快照日志时oracle数据库为我们建立了一个基于yh_qfcx的触发器tlog$_yh_qfcx和快照日志表mlog$_yh_qfcx;建立快照时oracle数据库为我们建立了一个表、两个视图、一个索引,它们分别为:

  一个表:snap$_s_yh_qfcx;

  两个视图:mview$_s_yh_qfcx和s_yh_qfcx;

  一个索引:I_snap$_s_yh_qfcx(

  基于表snap$_s_yh_qfcx中的m_row$$字段。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

MySQL's Role: Databases in Web ApplicationsMySQL's Role: Databases in Web ApplicationsApr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

MySQL: Building Your First DatabaseMySQL: Building Your First DatabaseApr 17, 2025 am 12:22 AM

The steps to build a MySQL database include: 1. Create a database and table, 2. Insert data, and 3. Conduct queries. First, use the CREATEDATABASE and CREATETABLE statements to create the database and table, then use the INSERTINTO statement to insert the data, and finally use the SELECT statement to query the data.

MySQL: A Beginner-Friendly Approach to Data StorageMySQL: A Beginner-Friendly Approach to Data StorageApr 17, 2025 am 12:21 AM

MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools