【正文】
表與視圖中增加新行 ) insert into emp values(8888,‘ abc’ ,‘ clerk’ ,0000,sysdate,2023,0,10)。 – for upfate select empno,sal,m from emp,dept where job=‘ CLERK’ and = and loc=‘ NEW YORK’ for update。 Oracle SQL, SQL*Plus and PL*SQL ? DML – Select (從一個(gè)或多個(gè)表或視圖中檢索數(shù)據(jù) ) select empno,ename,sal,deptno from emp where deptno=10。 – PL*SQL ? 是 Oracle的一種過程化的SQL語言。不能更新、插入、 刪除。 summary In this lesson, you should have learned how to: ? Explain database files: data files, control files, online redo logs ? Explain SGA memory structures: DB buffer cache, shared SQL pool, and redo log buffer ? Explain primary background processes: DBW0, LGWR, CKPT, PMON, SMON, and ARC0 ? Explain SQL processing steps: parse, execute, fetch 數(shù)據(jù)字典 數(shù)據(jù)字典 Data Dictionary ? 數(shù)據(jù)字典 – 數(shù)據(jù)字典是 Oracle數(shù)據(jù)庫的重要組成。它Oracle Server被用來作為內(nèi)部的時(shí)間戳,來同步數(shù)據(jù)及保證數(shù)據(jù)讀一致性。 . 4 server記錄信息顯示事務(wù)已經(jīng)完成,鎖可以被釋放。 COMMITs 步驟 當(dāng) COMMIT 執(zhí)行時(shí): 1 server在 redo log Buffer中放置一個(gè) SCN作為mit記號(hào) 。 ) ? PGA(程序全局區(qū)) – 是內(nèi)存中的區(qū)域,包含單個(gè)進(jìn)程的數(shù)據(jù)和控制信息。 – ? Log Writer (LGWR) 負(fù)責(zé)將數(shù)據(jù)更改記錄由 redo log buffer寫到redo log files. – ? System Monitor (SMON) 檢查數(shù)據(jù)庫的一致性,必要的情況下,在數(shù)據(jù)庫打開時(shí)執(zhí)行恢復(fù)。 另外在 SGA中還有兩個(gè)可選的內(nèi)存結(jié)構(gòu): ? Java pool: 用來存儲(chǔ) Java代碼。 SGA包含如下內(nèi)存結(jié)構(gòu): ? 共享池 (shared pool) 用來存儲(chǔ)最近執(zhí)行的 SQL語句和最近使用的數(shù)據(jù)字典 (data dictionary)的數(shù)據(jù)。Instance被看成使用各個(gè)操作系統(tǒng)的特定方法 instance 只能同時(shí)打開和使用一個(gè) database 。 ? 在 Oracle數(shù)據(jù)庫創(chuàng)建時(shí),初始參數(shù)文件的 DB_BLOCK_SIZE 確定 Oracle數(shù)據(jù)庫 Data block的大小。 ? 一個(gè) extent 由一系列連續(xù)的 Oracle blocks組成。 區(qū)間 Extents 通過 extent 來給 segment分配空間。例如 , 為表分配的所有存儲(chǔ)空間就是就是一個(gè) segment。 ? 一個(gè)數(shù)據(jù)文件只能屬于一個(gè) tablespace。 – 除了 SYSTEM tablespace 或 有活動(dòng)回滾段的 tablespace , tablespaces 可以被離線 (offline)。 – 存檔重做日志文件 是重做日志的備份用以恢復(fù)數(shù)據(jù)。一個(gè)數(shù)據(jù)庫需要至少一個(gè)控制文件。 –一個(gè)或者多個(gè)數(shù)據(jù)文件構(gòu)成數(shù)據(jù)庫的邏輯存儲(chǔ)單元叫做表空間 (tablespace). ? 重作日志 (Redo logs) 包含對(duì)數(shù)據(jù)庫的修改記錄,可以在數(shù)據(jù)失敗后恢復(fù)。數(shù)據(jù)包含在用戶定義的表中,而且數(shù)據(jù)文件還包含數(shù)據(jù)詞典 (data dictionary),數(shù)據(jù)修改以前的映象(beforeimages of modified Data)索引 (indexes)和其他類型的結(jié)構(gòu) (other types of structures)。 特點(diǎn) 高性能、伸縮性 安全性:角色、權(quán)限、用戶 并發(fā)控制:表鎖定、行鎖定 海量數(shù)據(jù):表空間、空間數(shù)據(jù)構(gòu)件 TB級(jí) 數(shù)據(jù)完整性:日志、回滾段 分布式數(shù)據(jù)庫:數(shù)據(jù)庫連接 Oracle 概述、特點(diǎn) 發(fā)展和構(gòu)成 發(fā)展史 性能不如 sybase 分區(qū)技術(shù)支持分段的大型數(shù)據(jù)庫 面向?qū)ο? 面向 inter 支持 java 、 webserver、 jdeveloper 9i portal 手機(jī)上網(wǎng) oracle體系結(jié)構(gòu) Oracle體系結(jié)構(gòu)決定了數(shù)據(jù)庫如何使用內(nèi)存、硬盤、 cpu和網(wǎng)絡(luò) 一個(gè) Oracle server包括一個(gè) Oracle實(shí)例 (instance)和幾個(gè) Oracle數(shù)據(jù)庫文件 (database file). 實(shí)例 數(shù)據(jù)庫文件 Oracle instance 實(shí)例 = 內(nèi)存分配 + 一組后臺(tái)進(jìn)程 如果把 Oracle比作一部汽車, instance相當(dāng)于汽車的發(fā)動(dòng)機(jī)一樣 ,啟動(dòng) oracle前提應(yīng)先啟動(dòng) instance..內(nèi)存被分配,進(jìn)程被啟動(dòng) SGA background process Oracle文件 一個(gè) Oracle 數(shù)據(jù)庫是一個(gè)數(shù)據(jù)單位的集合。孟憲順 202331 Genersoft Inc. Oracle DBA Oracle ocp course content Architecture and Administration Oracle結(jié)構(gòu)和維護(hù): 1. Oracle 特點(diǎn)、結(jié)構(gòu) 2. 創(chuàng)建數(shù)據(jù)庫 3. Oracle 數(shù)據(jù)庫的訪問 4. Managing an Oracle Instance 5. Maintaining the Control File 6. Maintaining Redo Log Files 7. Managing Tablespaces and Data Files 8. Managing Rollback Segments 9. Managing Users, privileges, roles 概述 ORACLE具有甲骨文之意,是全世界第二大軟件公司。 主要目的是為了儲(chǔ)存和讀取信息。一個(gè)數(shù)據(jù)庫中至少包含一個(gè)數(shù)據(jù)文件。一個(gè)數(shù)據(jù)需要至少 兩 個(gè)重作日志文件。 其它文件 ? 其他文件 – 參數(shù)文件 用來定義 Oracle實(shí)例的特性。 Oracle 數(shù)據(jù)庫邏輯與物理結(jié)構(gòu) Database Architecture 數(shù)據(jù)庫結(jié)構(gòu) (Database Architecture) Oracle 數(shù)據(jù)庫結(jié)構(gòu)包括物理 (physical)和邏輯 (logical)結(jié)構(gòu) ? 物理 (physical)結(jié)構(gòu)包括控制文件 (control files), 在線重作日志 (online redo log files), 和數(shù)據(jù)文件 (data files). ? 邏輯 logical結(jié)構(gòu)包括表空間 (tablespaces), 段 (segments), 區(qū)間 (extents), 和數(shù)據(jù)塊 (data blocks). Oracle server 可以有條理的通過表空間以及段、擴(kuò)展、數(shù)據(jù)塊控制磁盤空間 表空間 (Tablespaces) Oracle database 的數(shù)據(jù)存儲(chǔ)在表空間中。 – Tablespaces 可以在讀 /寫之間切換。 ? Oracle 服務(wù)為表空間創(chuàng)建一個(gè)數(shù)據(jù)文件,分配指定的磁盤空間再加上額外的一小部分開銷。 ? 一個(gè) tablespace可能包含一個(gè)或多個(gè) Segment . ? segment不能跨越 tablespace 。 ? 一個(gè)或多個(gè) extents組成一個(gè) segment. – 當(dāng)一個(gè) segment創(chuàng)建時(shí),至少包含一個(gè) extent 。 ? 一個(gè) extent 不能跨越 data file, 但必須存在 data file中。 ? Data block的大小應(yīng)該為操作系統(tǒng)塊的整數(shù)倍,以減少 I/O量。 System Global Area SGA是存儲(chǔ)數(shù)據(jù)庫進(jìn)程共享的數(shù)據(jù)庫信息的內(nèi)存區(qū)域。這些 SQL語句可能是被用戶遞交的也可能是存儲(chǔ)過程調(diào)用的。 ? Large pool: 用來存儲(chǔ)不與 SQL直接相關(guān)的大型內(nèi)存結(jié)構(gòu)。 – ? Process Monitor (PMON)用戶進(jìn)程失敗時(shí),進(jìn)程監(jiān)控程序?qū)崿F(xiàn)進(jìn)程恢復(fù)。每個(gè)服務(wù)器進(jìn)程分配一個(gè) PGA, PGA由每個(gè)服務(wù)器進(jìn)程獨(dú)占。 2 LGWR 執(zhí)行一個(gè)不間斷的寫操作包括所有的 redo log buffer寫到 redo log files及 mit記號(hào)。 數(shù)據(jù)緩沖信息獨(dú)立的由 DBW0執(zhí)行,可能在 mit前也可能在Commit后。使用 SCN 可以不依靠操作系統(tǒng)時(shí)間來檢驗(yàn)一致性。它由一組只讀表組成。數(shù)據(jù)字典的改變會(huì)影響數(shù)據(jù)庫的正常運(yùn)行。他有自己的程序結(jié)構(gòu), 有各種條件控制和循環(huán)控制。 ? 復(fù)雜的 select 語句: – group by 子句 select deptno,min(sal),max(sal) from emp group by deptno。 select empno,sal,m from emp,dept where job=‘ CLERK’ and = and loc=‘ NEW YORK’ for update of 。 – delete (從表與視圖中刪除行 ) delete from emp where deptno=10。 this allows any valid user to connect to the database and perform typical data access operations. Opening the database includes the following tasks: ? Opening the online data files ? Opening the online redo log files If any of the data files or online redo log files are not present when you attempt to open the database, the Oracle server returns an error. During this final stage, the Oracle server verifies that all the data files and online redo log files can be opened and checks the consistency of the database. If necessary, the System Monitor background process (SMON) initiates instance recovery. Starting Up To start up an instance, use the following mand: STARTUP [FORCE] [RESTRICT] [PFILE= filename] [OPEN [RECOVER][ database] |MOUNT |NOMOUNT] To open the database from STARTUP NOMOUNT to a MOUNT stage or from MOUNT to an OPEN stage, use the ALTER DATABASE mand: ALTER DATABASE { MOUNT | OPEN } ALTER DATABASE OPEN [READ WRITE| READ ONLY] Example: – Start up the instance and open the database: STARTUP PFILE=/DISK1/initU15. – Change the state of the database from NOMOUNT to MOUNT: ALTER DATABASE database MOUNT。 回滾表空間 用于 保存回滾段 不 要包含其他永久性數(shù)據(jù) CREATE TABLESPACE rbs DATAFILE ?DISK2/?SIZE 50M MINIMUM EXTENT 1M DEFAULT STORAGE (INITIAL 2M NEXT 2M MAXEXTENTS 500 PCTINCREASE 0) 。 Tablespace APP_ DATA