1 Oracle创建简单项目环境1)创建表空间SQLgt; create tablespace dreamtry_tbs datafile
1 Oracle创建简单项目环境
1)创建表空间
SQL> create tablespace dreamtry_tbs datafile 'd:\oracledate\dreamtry_tbs01.dbf' size 100M;
表空间已创建。
2)创建用户
SQL> create user dreamtry identified by dreamtry;
用户已创建。
3)给用户分配表空间
SQL> alter user dreamtry default tablespace dreamtry_tbs quota unlimited on dreamtry_tbs;
用户已更改。
4)取消用户对表空间都拥有写权限(这点非必须,建议执行)
SQL> alter user dreamtry default tablespace dreamtry_tbs quota unlimited on dreamtry_tbs;
用户已更改。
5)给用户分配基本权限 (可以加上with admin option)
SQL> grant connect,resource to dreamtry;
授权成功。
6)切换用户
SQL> conn dreamtry/dreamtry;
已连接。
2 模拟数据文件丢失的恢复(前提是以前有过备份,并且有日志)
1) 备份数据文件
RMAN> backup datafile 'd:\oracledate\dreamtry_tbs01.dbf' format 'D:\oracle\product\10.2.0\oradata\orcl\dreamtry_tbs01.dbf';
启动 backup 于 01-3月 -12
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=145 devtype=DISK
通道 ORA_DISK_1: 启动全部数据文件备份集
通道 ORA_DISK_1: 正在指定备份集中的数据文件
输入数据文件 fno=00007 name=D:\ORACLEDATE\DREAMTRY_TBS01.DBF
通道 ORA_DISK_1: 正在启动段 1 于 01-3月 -12
通道 ORA_DISK_1: 已完成段 1 于 01-3月 -12
段句柄=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\DREAMTRY_TBS01.DBF 标记=TAG20120301T223142 注释=NONE
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:03
完成 backup 于 01-3月 -12
2) 切换用户dreamtry模拟数据操作
SQL> conn dreamtry/dreamtry;
已连接。
SQL> create table test(id number(10), name varchar2(20));
表已创建。
SQL> insert into test(id,name) values(1,'zhangsan');
已创建 1 行。
SQL> select * from test;
ID NAME
---------- --------------------
1 zhangsan
3) 模拟数据文件dreamtry_tbs01.dfb丢失
手工删除OS文件dreamtry_tbs01.dbf(移到别处也可,以防万一)
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 251661188 bytes
Database Buffers 352321536 bytes
Redo Buffers 7135232 bytes
数据库装载完毕。
ORA-01157: 无法标识/锁定数据文件 7 - 请参阅 DBWR 跟踪文件
ORA-01110: 数据文件 7: 'D:\ORACLEDATE\DREAMTRY_TBS01.DBF'
SQL> select status from v$instance;
STATUS
------------
MOUNTED
如上数据库只能启动mount状态.
4) 使用备份的数据文件恢复(当然在有日志的情况下没有备份也是可以恢复的)
RMAN> restore datafile 7;
启动 restore 于 01-3月 -12
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在开始恢复数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集恢复的数据文件
正将数据文件00007恢复到D:\ORACLEDATE\DREAMTRY_TBS01.DBF
通道 ORA_DISK_1: 正在读取备份段 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\DREAMTRY_TBS01.DBF
通道 ORA_DISK_1: 已恢复备份段 1
段句柄 = D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\DREAMTRY_TBS01.DBF 标记 = TAG20120301T223142
通道 ORA_DISK_1: 恢复完成, 用时: 00:00:04
完成 restore 于 01-3月 -12
5) 通过日志恢复备份以后操作数据库的内容
RMAN> recover datafile 7;
启动 recover 于 01-3月 -12
使用通道 ORA_DISK_1
正在开始介质的恢复
介质恢复完成, 用时: 00:00:03
完成 recover 于 01-3月 -12
6) 打开数据库
RMAN> alter database open;
数据库已打开
7) 验证数据
SQL> select * from dreamtry.test;
ID NAME
---------- --------------------
1 zhangsan
8) 由于是模拟,我还是把备份删掉以免占用空间
RMAN> list backup;
备份集列表
===================
BS 关键字 类型 LV 大小 设备类型 经过时间 完成时间
------- ---- -- ---------- ----------- ------------ ----------
3 Full 88.00K DISK 00:00:02 01-3月 -12
BP 关键字: 3 状态: AVAILABLE 已压缩: NO 标记: TAG20120301T223142
段名:D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\DREAMTRY_TBS01.DBF
备份集 3 中的数据文件列表
文件 LV 类型 Ckp SCN Ckp 时间 名称
---- -- ---- ---------- ---------- ----
7 Full 1068184 01-3月 -12 D:\ORACLEDATE\DREAMTRY_TBS01.DBF
RMAN> delete backupset 3;
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=145 devtype=DISK
备份段列表
BP 关键字 BS 关键字 Pc# Cp# 状态 设备类型段名称
------- ------- --- --- ----------- ----------- ----------
3 3 1 1 AVAILABLE DISK D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\DREAMTRY_TBS01.DBF
是否确定要删除以上对象 (输入 YES 或 NO)? YES
已删除备份段
备份段 handle=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\DREAMTRY_TBS01.DBF recid=3 stamp=776817102
1 对象已删除
RMAN> crosscheck backup;
使用通道 ORA_DISK_1
RMAN> delete expired backup;
使用通道 ORA_DISK_1
9) 结论:日志是最后一道防线,所以最好先备份,最好也对archive log也备份,还是以防万一.

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

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 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 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.

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.

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


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

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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.

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