search
HomeDatabaseMysql TutorialOracle备份与恢复系列

创建测试用户snow,该用户拥有一个表,一个存储过程,一项任务起作用很简单,就是模拟一个用户每分钟像数据库插入一条时间戳,产

实验环境简介:
 创建测试用户snow,,该用户拥有一个表,一个存储过程,一项任务起作用很简单,就是模拟一个用户每分钟像数据库插入一条时间戳,产生数据库行为。在备份与恢复的过程中,该时间戳可以检测恢复操作是否顺利完成。

--------------------------------------推荐阅读 --------------------------------------

RMAN 配置归档日志删除策略

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密

--------------------------------------分割线 --------------------------------------
 
查看数据库名称和归档模式
 SYS@PRACTICE >col name for a10
 SYS@PRACTICE >col log_mode for a10
 SYS@PRACTICE >select name, log_mode from v$database;
 
NAME      LOG_MODE
 ---------- ----------
 PRACTICE  ARCHIVELOG
 
查看数据库版本
 SYS@PRACTICE >select * from v$version;
 
BANNER
 --------------------------------------------------------------------------------
 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
 
数据文件
 SYS@PRACTICE >col name for a40
 SYS@PRACTICE >select name,bytes/1024/1024 MB from v$datafile;
 
NAME                                            MB
 ---------------------------------------- ----------
 /oradata/PRACTICE/system01.dbf                  710
 /oradata/PRACTICE/sysaux01.dbf                  570
 /oradata/PRACTICE/undotbs01.dbf                110
 /oradata/PRACTICE/users01.dbf                    5
 /oradata/PRACTICE/example01.dbf            313.125
 /oradata/PRACTICE/tools01.dbf                    20
 /oradata/PRACTICE/indx.dbf                      20
 
下面的语句也可以显示同样的数据
 select file_name, bytes/1024/1024 MB from dba_data_files;
 
查看联机重做日志的位置和大小
 SYS@PRACTICE >select member,bytes/1024/1024 MB from v$logfile lf, v$log l where lf.group# = l.group#;
 
MEMBER                                                              MB
 ------------------------------------------------------------ ----------
 /oradata/PRACTICE/redo03.log                                        50
 /oradata/PRACTICE/redo02.log                                        50
 /oradata/PRACTICE/redo01.log                                        50
 
查看控制文件的位置
 SYS@PRACTICE >col name for a100
 SYS@PRACTICE >select name from v$controlfile;
 
NAME
 --------------------------------------------------------------------------------
 /oradata/PRACTICE/control01.ctl
 /u01/app/oracle/fast_recovery_area/PRACTICE/control02.ctl
 
查看临时文件的位置及大小
 SYS@PRACTICE >select name,bytes/1024/1024 MB from v$tempfile;
 
NAME                                            MB
 ---------------------------------------- ----------
 /oradata/PRACTICE/temp01.dbf                    29
 

创建测试用户SNOW
 GRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO snow IDENTIFIED BY snow;
 
ALTER USER snow DEFAULT  TABLESPACE TOOLS;
 ALTER USER snow TEMPORARY TABLESPACE TEMP;
 

创建时间戳表
 CONNECT snow/snow
 
DROP TABLE date_log;
 CREATE TABLE date_log (
 create_time DATE CONSTRAINT create_date_pk PRIMARY KEY USING INDEX TABLESPACE INDX,
 name varchar2(10)
 );
 
col segment_name for a15
 col TABLESPACE_NAME for a15
 select segment_name,tablespace_name from user_segments;
 
SEGMENT_NAME    TABLESPACE_NAME
 --------------- ---------------
 DATE_LOG        TOOLS
 CREATE_DATE_PK  INDX
 
基于时间戳表创建一个存储过程
 conn snow/snow
 CREATE OR REPLACE PROCEDURE create_date_log_row
 IS
 BEGIN
  INSERT INTO date_log VALUES (SYSDATE,'--');
 END;
 /
 
创建一个job来执行存储过程,来模拟数据库在“运行中”
 每分钟执行一次
 conn snow/snow
 VARIABLE jobno number;
 BEGIN
 -- Run the job every 1 minutes
    DBMS_JOB.SUBMIT(:jobno, 'snow.create_date_log_row;', SYSDATE, '(SYSDATE + 1/(24*60))');
    commit;
 END;
 /
 
SNOW@PRACTICE >print jobno
 
    JOBNO
 ----------
        24
 
SNOW@PRACTICE >col what for a30
 SNOW@PRACTICE >SELECT job, what FROM USER_JOBS;
 
      JOB WHAT
 ---------- ------------------------------
        24 snow.create_date_log_row;

更多详情见请继续阅读下一页的精彩内容:

更多详情见请继续阅读下一页的精彩内容:

linux

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 String Types: Storage, Performance, and Best PracticesMySQL String Types: Storage, Performance, and Best PracticesMay 10, 2025 am 12:02 AM

MySQLstringtypesimpactstorageandperformanceasfollows:1)CHARisfixed-length,alwaysusingthesamestoragespace,whichcanbefasterbutlessspace-efficient.2)VARCHARisvariable-length,morespace-efficientbutpotentiallyslower.3)TEXTisforlargetext,storedoutsiderows,

Understanding MySQL String Types: VARCHAR, TEXT, CHAR, and MoreUnderstanding MySQL String Types: VARCHAR, TEXT, CHAR, and MoreMay 10, 2025 am 12:02 AM

MySQLstringtypesincludeVARCHAR,TEXT,CHAR,ENUM,andSET.1)VARCHARisversatileforvariable-lengthstringsuptoaspecifiedlimit.2)TEXTisidealforlargetextstoragewithoutadefinedlength.3)CHARisfixed-length,suitableforconsistentdatalikecodes.4)ENUMenforcesdatainte

What are the String Data Types in MySQL?What are the String Data Types in MySQL?May 10, 2025 am 12:01 AM

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

How to Grant Permissions to New MySQL UsersHow to Grant Permissions to New MySQL UsersMay 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

How to Add Users in MySQL: A Step-by-Step GuideHow to Add Users in MySQL: A Step-by-Step GuideMay 09, 2025 am 12:14 AM

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

MySQL: Adding a new user with complex permissionsMySQL: Adding a new user with complex permissionsMay 09, 2025 am 12:09 AM

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

MySQL: String Data Types and CollationsMySQL: String Data Types and CollationsMay 09, 2025 am 12:08 AM

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

MySQL: What length should I use for VARCHARs?MySQL: What length should I use for VARCHARs?May 09, 2025 am 12:06 AM

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

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

Video Face Swap

Video Face Swap

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

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment