Oracle 10g手工建立資料庫

來源:互聯網
上載者:User

  1、建立目錄

  mkdir d:oracleproduct10.1.0database

  mkdir e:oracleadminOra10gdump

  mkdir e:oracleadminOra10gcdump

  mkdir e:oracleadminOra10gcreate

  mkdir e:oracleadminOra10gpfile

  mkdir e:oracleadminOra10gudump

  mkdir e:oracleflash_recovery_area

  mkdir e:oracleoradata

  mkdir e:oracleoradataOra10g

  2、產生windows服務,建立密碼檔案,在cmd命令下運行

  set ORACLE_SID=dbca --綠色部分設定oracle 執行個體名為 為ora10g

  d:oracleproduct10.1.0DB_1inoradim.exe -new -sid ORA10G -startmode manual -spfile d:oracleproduct10.1.0DB_1inoradim.exe -edit -sid ORA10G -startmode a -spfile

  --建立一個執行個體名為dbca 並且有手動啟動方式改為自動啟動

  d:oracleproduct10.1.0DB_1inorapwd.exe file=d:oracleproduct10.1.0db_1PWDOra10g.ora password=sysPassword force=y

  --用oracle內建的orapwd 為sys使用者建立一個預設的密碼為sysPassword

  3、執行建立資料庫指令碼

  D:oracleora92insqlplus /nolog @D:oracleadmindbcascriptsCreateDB.sql

  D:oracleora92insqlplus /nolog @D:oracleadmindbcascriptsCreateDBFiles.sql

  D:oracleora92insqlplus /nolog @D:oracleadmindbcascriptsCreateDBCatalog.sql

  D:oracleora92insqlplus /nolog @D:oracleadmindbcascriptspostDBCreation.sql

  --黑體部分就是建立資料庫要調用的指令碼

  第一 CreateDB.sql

  connect SYS/change_on_install as SYSDBA --這是剛剛我們設定的密碼以sysdba身份串連到資料庫

  connect SYS/change_on_install as SYSDBA --這是剛剛我們設定的密碼以sysdba身份串連到資料庫

  set echo on

  spool D:oracleora92assistantsdbcalogsCreateDB.log 寫日誌

  startup nomount pfile="D:oracleadmindbcascriptsinit.ora"; 調用參數檔案 啟動資料庫到只裝載執行個體階段

  CREATE DATABASE dbca

  MAXINSTANCES 1

  MAXLOGHISTORY 1

  MAXLOGFILES 5

  MAXLOGMEMBERS 3

  MAXDATAFILES 100 --控制檔案記錄的相關最大日誌數,日誌組,最大資料檔案數等限制

  DATAFILE 'D:oracleoradatadbcasystem01.dbf' SIZE 250M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED

  EXTENT MANAGEMENT LOCAL

  DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE 'D:oracleoradatadbca emp01.dbf' SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED

  UNDO TABLESPACE "UNDOTBS1" DATAFILE 'D:oracleoradatadbcaundotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED --建立系統,臨時,復原 資料表空間ITPUB個人空間!dJ5l {!i4W r f

  CHARACTER SET ZHS16GBK

  NATIONAL CHARACTER SET AL16UTF16 --字元集

  LOGFILE GROUP 1 ('D:oracleoradatadbca edo01.log') SIZE 102400K,

  GROUP 2 ('D:oracleoradatadbca edo02.log') SIZE 102400K,

  GROUP 3 ('D:oracleoradatadbca edo03.log') SIZE 102400K; --建立記錄檔租和成員

  spool off

  exit;

  第二.CreateDBFiles.sql

  connect SYS/change_on_install as SYSDBA

  set echo on

  spool D:oracleora92assistantsdbcalogsCreateDBFiles.log

  CREATE TABLESPACE "INDX" LOGGING DATAFILE 'D:oracleoradatadbcaindx01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;

  CREATE TABLESPACE "TOOLS" LOGGING DATAFILE 'D:oracleoradatadbca ools01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;

  CREATE TABLESPACE "USERS" LOGGING DATAFILE 'D:oracleoradatadbcausers01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ; --建立相關使用者要用到的資料表空間

  spool off

  exit;

  第三:CreateDBCatalog.sql

  --建立system資料字典,存放到system資料表空間,相關表,視圖等

  connect SYS/change_on_install as SYSDBA

  set echo on

  spool D:oracleora92assistantsdbcalogsCreateDBCatalog.log

  @D:oracleora92 dbmsadmincatalog.sql;

  @D:oracleora92 dbmsadmincatexp7.sql;

  @D:oracleora92 dbmsadmincatblock.sql;

  @D:oracleora92 dbmsadmincatproc.sql;

  @D:oracleora92 dbmsadmincatoctk.sql;

  @D:oracleora92 dbmsadminowminst.plb;

  connect SYSTEM/manager

  @D:oracleora92sqlplusadminpupbld.sql;

  connect SYSTEM/manager

  set echo on

  spool D:oracleora92assistantsdbcalogssqlPlusHelp.log

  @D:oracleora92sqlplusadminhelphlpbld.sql helpus.sql;

  spool off

  spool off

  exit;

  第四: postDBCreation.sql

  connect SYS/change_on_install as SYSDBA

  set echo on

  spool D:oracleora92assistantsdbcalogspostDBCreation.log

  @D:oracleora92 dbmsadminutlrp.sql; --編譯相關視圖,包對象等

  shutdown ; --關閉資料庫

  connect SYS/change_on_install as SYSDBA

  set echo on

  spool D:oracleora92assistantsdbcalogspostDBCreation.log

  create spfile='D:oracleora92databasespfiledbca.ora' FROM pfile='D:oracleadmindbcascriptsinit.ora';

  --建立伺服器參數檔案代替檔案初始化參數檔案,方便有時在不重啟資料庫的情況下可以使參數生效

  從上面可以看到spfile檔案的存放位置

  startup ; --啟動資料庫 ,建立資料庫完成

  exit;

  從上面可以看出,建立資料庫有以下10個步驟

  Step 1: 建立相關trace目錄檔案夾

  Step 2:建立執行個體,密碼 啟動方式

  Step 3:建立初始化參數檔案 init.ora

  Step 4: 串連到執行個體

  Step 5: 啟動執行個體到nomount狀態

  Step 6:建立資料庫

  Step 7:建立資料表空間

  Step 8: 運行指令碼建立資料字典

  Step 9: 建立伺服器參數檔案(這步不是必須的,但oracle建議做這步) 好處會在以後的總結中列出

  下面也貼出linux下指令碼,和windows下幾乎差不多

  #!/bin/sh

  mkdir /oradata/ora9i

  mkdir /oradata/ora9i/controlfile

  mkdir /oradata/ora9i/redofile

  mkdir /orasys/oracle/admin

  mkdir /orasys/oracle/admin/ora9i

  mkdir /orasys/oracle/admin/ora9i/bdump

  mkdir /orasys/oracle/admin/ora9i/cdump

  mkdir /orasys/oracle/admin/ora9i/create

  mkdir /orasys/oracle/admin/ora9i/udump

  mkdir /orasys/oracle/admin/ora9i/pfile

  cp init.ora /orasys/oracle/product/9.2.0/dbs/.

  export ORACLE_BASE=/orasys/oracle

  export ORACLE_HOME=$ORACLE_BASE/product/9.2.0

  export ORACLE_SID=ora9i

  export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data

  LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

  export LD_LIBRARY_PATH

  export PATH=$PATH:$ORACLE_HOME/bin

  echo Add this entry in the oratab: ora9i:/orasys/oracle/product/9.2.0:Y

  /orasys/oracle/product/9.2.0/bin/orapwd file=/orasys/oracle/product/9.2.0/dbs/orapwora9i password=change_on_install

  /orasys/oracle/product/9.2.0/bin/sqlplus /nolog @/home/oracle/create_script/CreateDB.sql

  /orasys/oracle/product/9.2.0/bin/sqlplus /nolog @/home/oracle/create_script/CreateDBFiles.sql

  /orasys/oracle/product/9.2.0/bin/sqlplus /nolog @/home/oracle/create_script/CreateDBCatalog.sql

  /orasys/oracle/product/9.2.0/bin/sqlplus /nolog @/home/oracle/create_script/postDBCreation.sql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.