手工建庫比起使用DBCA建庫來說,是比較麻煩的,但是如果我們學(xué)好了手工建庫的話,就可以使我們更好地理解Oracle數(shù)據(jù)庫的體系結(jié)構(gòu)。手工建庫須要經(jīng)過幾個步驟,每一個步驟都非常關(guān)鍵。它包括:
          1、 創(chuàng)建必要的相關(guān)目錄
          2、 創(chuàng)建初始化參數(shù)文件
          3、 設(shè)置環(huán)境變量Oracle_sid
          4、 創(chuàng)建實例
          5、 創(chuàng)建口令文件
          6、 啟動數(shù)據(jù)庫到nomount(實例)狀態(tài)
          7、 執(zhí)行建庫腳本
          8、 執(zhí)行catalog腳步本創(chuàng)建數(shù)據(jù)字典
          9、 執(zhí)行catproc創(chuàng)建package包
          10、 執(zhí)行pupbld
          11、 由初始化參數(shù)文件創(chuàng)建spfile文件
          12、 執(zhí)行scott腳本創(chuàng)建scott模式

          通過手動創(chuàng)建oracle數(shù)據(jù)庫,可以了解oracle數(shù)據(jù)庫的結(jié)構(gòu)和數(shù)據(jù)庫運行機制,對理解oracle數(shù)據(jù)庫有幫助
          一、打開命令行工具,創(chuàng)建必要有相關(guān)目錄
          mkdir D:applenovoadmincwj

          mkdir D:applenovoadmincwjadump

          mkdir D:applenovoadmincwjdpdump

          mkdir D:applenovoadmincwjpfile

          mkdir D:applenovoflash_recovery_areacwj

          mkdir D:applenovooradatacwj

          上面創(chuàng)建目錄的過程也可以在Windows的圖形界面中去創(chuàng)建。其中D:applenovoadmincwj
          目錄下的幾個子目錄主要用于存放數(shù)據(jù)庫運行過程中的跟蹤信息。最重要的兩上子目錄是adump和dpdump目錄,adump目錄存放的是數(shù)據(jù)庫動行過程中的各個后臺進(jìn)程的跟蹤信息,當(dāng)中alert文件是警告文件,其文件名稱為alert_cwj.log,當(dāng)數(shù)據(jù)庫出現(xiàn)問題時,首先就可以去查看此文件以找出原因,手工創(chuàng)建過程中出現(xiàn)的各種問題往往也可以通過查看這個文件找到原因。Udump目錄存放和特定會話相關(guān)的跟蹤信息。D:applenovooradatacwj目錄存放各種數(shù)據(jù)庫文件,包括控制文件、數(shù)據(jù)文件、重做日志文件。
          二、創(chuàng)建初始化參數(shù)文件
          數(shù)據(jù)庫系統(tǒng)啟動時須要用初始化參數(shù)文件的設(shè)置分配內(nèi)存、啟動必要的后臺進(jìn)程的。因此,初始化參數(shù)文件創(chuàng)建的是否正確、參數(shù)設(shè)置是否正確關(guān)系著整個建庫的“命運”。
          創(chuàng)建初始化參數(shù)文件可以通過拷貝現(xiàn)在的初始化參數(shù)文件并將其做適當(dāng)?shù)男薷募纯?,從而不必要用手工去一句一句地寫出來,因為初始化參?shù)文件的結(jié)構(gòu)體系基本上都是一樣的。在我們安裝Oracle的時候,系統(tǒng)已經(jīng)為我們安裝了一個名為studyoracle的數(shù)據(jù)庫,于是我們可以從它那里得到一份初始化參數(shù)文件。打開D:\app\lenovo\admin\studyoracle\pfile,找到init.ora.2182017155336文件,把它拷貝到D:\app\lenovo\admin\cwj\pfile下,并將其改名為initcwj.ora。接著用記事本的方式打開initcwj.ora,修改以下的內(nèi)容:
          ##############################################################################
          Copyright (c) 1991, 2001, 2002 by Oracle Corporation

          NLS

          nls_language="SIMPLIFIED CHINESE"
          nls_territory="CHINA"

          Shared Server

          dispatchers="(PROTOCOL=TCP) (SERVICE=studyoracleXDB)"

          Miscellaneous

          compatible=11.2.0.0.0
          db_unique_name=studyoracle
          diagnostic_dest=D:applenovo
          memory_target=3313500160

          Security and Auditing

          audit_file_dest=D:applenovoadmincwjadump
          audit_trail=db
          remote_login_passwordfile=EXCLUSIVE

          Database Identification

          db_domain=""
          db_name=studyora

          File Configuration

          control_files=("D:applenovooradatacwjcontrol01.ctl",
          "D:applenovoflash_recovery_areacwjcontrol02.ctl")
          db_recovery_file_dest=D:applenovoflash_recovery_area
          db_recovery_file_dest_size=4102029312

          Cursors and Library Cache

          open_cursors=300

          System Managed Undo and Rollback Segments

          undo_tablespace=UNDOTBS1

          Processes and Sessions

          processes=150

          Cache and I/O

          db_block_size=8192

          三、打開命令行,設(shè)置環(huán)境變量oracle_sid

          C:Userslenovo>oradim -new -sid cwj

          oradim是創(chuàng)建實例的工具程序名稱,-new表明執(zhí)行新建實例,-delete表明執(zhí)行刪掉實例,-sid指定害例的名稱。

          五、創(chuàng)建口令文件
          C:Userslenovo>orapwd file=D:applenovoproduct11.2.0dbhome_1databasePWDcwj.ora
          password=manager entries=2


          orapwd是創(chuàng)建口令文件的工肯程序各稱,file參數(shù)指定口令文件所在的目錄和文件名稱,password參數(shù)指定sys用戶的口令,entries參數(shù)指定數(shù)據(jù)庫擁用DBA權(quán)限的用戶的個數(shù)。


          口令文件是專門存放sys用戶的口令,因為sys用戶要負(fù)責(zé)建庫、啟動數(shù)據(jù)庫、關(guān)閉數(shù)據(jù)庫等特殊任務(wù),把以sys用戶的口令單獨存放于口令文件中,這樣數(shù)據(jù)庫末打開時也能進(jìn)行口令驗證

          六、啟動數(shù)據(jù)庫到nomount(實例)狀態(tài)
          startup pfile='D:applenovoadmincwjpfileinitcwj.ora' nomount
          C:Userslenovo>sqlplus /nolog

          SQL*Plus: Release 11.2.0.1.0 Production on 星期四 12月 20 10:19:53 2018

          Copyright (c) 1982, 2010, Oracle. All rights reserved.

          SQL> conn sys/manager as sysdba
          SQL> startup pfile='D:applenovoadmincwjpfileinitcwj.ora' nomount
          ORACLE 例程已經(jīng)啟動。

          Total System Global Area 3307048960 bytes
          Fixed Size 2180264 bytes
          Variable Size 1811942232 bytes
          Database Buffers 1476395008 bytes
          Redo Buffers 16531456 bytes
          SQL>
          七、執(zhí)行建庫腳本
          create database cwj
          datafile
          'D:\app\lenovo\oradata\cwj\system01.dbf' size 300m Autoextend on next 10m
          maxsize unlimited
          sysaux datafile
          'D:\app\lenovo\oradata\cwj\sysaux01.dbf' size 300m Autoextend on next 10m
          maxsize unlimited
          undo tablespace UNDOTBS1 datafile
          'D:\app\lenovo\oradata\cwj\undotbs01.dbf' size 50m
          default temporary tablespace temp tempfile
          'D:\app\lenovo\oradata\cwj\temp01.dbf' size 30m
          logfile
          group 1 ('D:applenovooradatacwjredo01.log') size 10240k,
          group 2 ('D:applenovooradatacwjredo02.log') size 10240k,
          group 3 ('D:applenovooradatacwjredo03.log') size 10240k
          character set zhs16gbk;

          SQL> create database cwj
          2 datafile
          3 'D:applenovooradatacwjsystem01.dbf' size 300m
          4 Autoextend on next 10m maxsize unlimited
          5 sysaux datafile
          6 'D:applenovooradatacwjsysaux01.dbf' size 300m
          7 Autoextend on next 10m maxsize unlimited
          8 undo tablespace UNDOTBS1 datafile
          9 'D:applenovooradatacwjundotbs01.dbf' size 50m
          10 default temporary tablespace temp tempfile
          11 'D:applenovooradatacwjtemp01.dbf' size 30m
          12 logfile
          13 group 1 ('D:applenovooradatacwjredo01.log') size 10240k,
          14 group 2 ('D:applenovooradatacwjredo02.log') size 10240k,
          15 group 3 ('D:applenovooradatacwjredo03.log') size 10240k
          16 character set zhs16gbk;

          數(shù)據(jù)庫已創(chuàng)建。

          八、執(zhí)行catalog腳步本創(chuàng)建數(shù)據(jù)字典

          start D:applenovoproduct11.2.0dbhome_1RDBMSADMINcatalog.sql

          九、執(zhí)行catproc創(chuàng)建package包

          SQL>start D:applenovoproduct11.2.0dbhome_1RDBMSADMINcatproc.sql

          十、執(zhí)行pupbld


          在執(zhí)行pupbld之前要把當(dāng)前用戶(sys)轉(zhuǎn)換成system,即以system賬戶連接數(shù)據(jù)庫。因為此數(shù)據(jù)庫是剛建的,所以system的口令是系統(tǒng)默認(rèn)的口令,即manager。你可以在數(shù)據(jù)庫建好以后再來重新設(shè)置此賬戶的口令。

          SQL>connect system/manager
          SQL>start D:applenovoproduct11.2.0dbhome_1sqlplusadminpupbld.sql

          十一、 由初始化參數(shù)文件創(chuàng)建spfile文件

          SQL>create spfile from pfile='D:applenovoadmincwjpfileinitcwj.ora';

          十二、 執(zhí)行scott腳本創(chuàng)建scott模式

          SQL>start D:applenovoproduct11.2.0dbhome_1RDBMSADMINscott.sql

          十三、 把數(shù)據(jù)庫打開到正常狀態(tài)
          SQL>alter database open;

          從 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
          With the Partitioning, OLAP, Data Mining and Real Application Testing options
          斷開

          C:Userslenovo>set oracle_sid=sky

          C:Userslenovo>sqlplus / as sysdba

          SQL*Plus: Release 11.2.0.1.0 Production on 星期四 12月 20 11:04:57 2018

          Copyright (c) 1982, 2010, Oracle. All rights reserved.

          SQL> exit
          從 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
          With the Partitioning, OLAP, Data Mining and Real Application Testing options
          斷開

          C:Userslenovo>conn sys/manager as sysdba
          'conn' 不是內(nèi)部或外部命令,也不是可運行的程序
          或批處理文件。

          C:Userslenovo>sqlplus /nolog

          SQL*Plus: Release 11.2.0.1.0 Production on 星期四 12月 20 11:05:38 2018

          Copyright (c) 1982, 2010, Oracle. All rights reserved.

          SQL> conn sys/manager as sysdba
          已連接。
          SQL> alter database open;
          alter database open
          *
          第 1 行出現(xiàn)錯誤:
          ORA-01531: 實例已打開數(shù)據(jù)庫

          SQL> exit
          從 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
          With the Partitioning, OLAP, Data Mining and Real Application Testing options
          斷開

          C:Userslenovo>lsnrctl status

          LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 20-12月-2018
          11:06:05

          Copyright (c) 1991, 2010, Oracle. All rights reserved.

          正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lenovo-PC)(PORT=1521)))

          LISTENER 的 STATUS

          別名 LISTENER
          版本 TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
          啟動日期 20-12月-2018 09:23:53
          正常運行時間 0 天 1 小時 42 分 13 秒
          跟蹤級別 off
          安全性 ON: Local OS Authentication
          SNMP OFF
          監(jiān)聽程序參數(shù)文件 D:applenovoproduct11.2.0dbhome_1networkadminlistener.ora
          監(jiān)聽程序日志文件 d:applenovodiagtnslsnrlenovo-PClisteneralertlog.xml
          監(jiān)聽端點概要...
          (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lenovo-PC)(PORT=1521)))
          (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\.pipeEXTPROC1521ipc)))
          服務(wù)摘要..
          服務(wù) "CLRExtProc" 包含 1 個實例。
          實例 "CLRExtProc", 狀態(tài) UNKNOWN, 包含此服務(wù)的 2 個處理程序...
          服務(wù) "sky" 包含 1 個實例。
          實例 "sky", 狀態(tài) READY, 包含此服務(wù)的 1 個處理程序...
          服務(wù) "studyoracle" 包含 1 個實例。
          實例 "studyoracle", 狀態(tài) READY, 包含此服務(wù)的 1 個處理程序...
          服務(wù) "studyoracleXDB" 包含 2 個實例。
          實例 "sky", 狀態(tài) READY, 包含此服務(wù)的 1 個處理程序...
          實例 "studyoracle", 狀態(tài) READY, 包含此服務(wù)的 1 個處理程序...
          命令執(zhí)行成功

          C:Userslenovo>sqlplus / as sysdba

          SQL*Plus: Release 11.2.0.1.0 Production on 星期四 12月 20 11:07:29 2018

          Copyright (c) 1982, 2010, Oracle. All rights reserved.

          連接到:
          Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
          With the Partitioning, OLAP, Data Mining and Real Application Testing options

          SQL> select * from scott.emp;
          EMPNO ENAME JOB MGR HIREDATE SAL COMM
          ---------- ---------- --------- ---------- -------------- ---------- ----------
          DEPTNO 7369 SMITH CLERK 7902 17-12月-80 800 20 7499 ALLEN SALESMAN 7698 20-2月
          -81 1600 300 30 7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30 EMPNO ENAME JOB
          MGR HIREDATE SAL COMM
          ---------- ---------- --------- ---------- -------------- ---------- ----------
          DEPTNO 7566 JONES MANAGER 7839 02-4月 -81 2975 20 7654 MARTIN SALESMAN 7698
          28-9月 -81 1250 1400 30 7698 BLAKE MANAGER 7839 01-5月 -81 2850 30 EMPNO ENAME
          JOB MGR HIREDATE SAL COMM
          ---------- ---------- --------- ---------- -------------- ---------- ----------
          DEPTNO 7782 CLARK MANAGER 7839 09-6月 -81 2450 10 7839 KING PRESIDENT
          17-11月-81 5000 10 7844 TURNER SALESMAN 7698 08-9月 -81 1500 0 30 EMPNO ENAME
          JOB MGR HIREDATE SAL COMM
          ---------- ---------- --------- ---------- -------------- ---------- ----------
          DEPTNO 7900 JAMES CLERK 7698 03-12月-81 950 30 7902 FORD ANALYST 7566
          03-12月-81 3000 20 7934 MILLER CLERK 7782 23-1月 -82 1300 10
          已選擇12行。

          SQL> exit
          從 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
          With the Partitioning, OLAP, Data Mining and Real Application Testing options
          斷開

          C:Userslenovo>sqlplus / as sysdba

          SQL*Plus: Release 11.2.0.1.0 Production on 星期四 12月 20 11:07:51 2018

          Copyright (c) 1982, 2010, Oracle. All rights reserved.

          連接到:
          Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
          With the Partitioning, OLAP, Data Mining and Real Application Testing options

          SQL> show parameter instance_name;

          NAME TYPE VALUE
          ------------------------------------ ----------- ------------------------------
          instance_name string sky
          SQL> alter user scott identified by tiger;

          用戶已更改。

          SQL> alter user sys identified by sys;

          用戶已更改。

          SQL>

          友情鏈接
          ioDraw流程圖
          API參考文檔
          OK工具箱
          云服務(wù)器優(yōu)惠
          阿里云優(yōu)惠券
          騰訊云優(yōu)惠券
          京東云優(yōu)惠券
          站點信息
          問題反饋
          郵箱:[email protected]
          QQ群:637538335
          關(guān)注微信

                午夜A片 婷婷久久综合久色综 | 性xxxxfreexxxxx高跟鞋 | 6~12呦孩精品XXXX视频视频 | 伦理4少妇按摩完整版 | 亚洲免费在线视频观看 |