windows7下oracle命令行手动创建数据库

Oracle windows 命令行创建数据库

1.设置系统环境变量 
ORACLE_HOME
C:\app\Administrator\product\11.2.0\dbhome_1
ORACLE_BASE
C:\app\Administrator

确保%ORACLE_HOME%\bin 在path路径下

2.命令行设置环境变量使用  set ORACLE_SID=ERP3

3.产生一个密码文件
windows下需要在ORACLE_HOME\database文件夹下
orapwd FILE=PWDERP3.ora PASSWORD=123456 ENTRIES=30

4.创建相关文件夹
ORACLE_BASE\admin\erp3
ORACLE_BASE\admin\erp3\adump
ORACLE_BASE\admin\erp3\dpdump

ORACLE_BASE\flash_recovery_area\erp3


ORACLE_BASE\oradata\erp3

5.创建初始化文件initERP3.ora;
 windows下需要在ORACLE_HOME\database文件夹下 内容如下
 
##############################################################################
# Copyright (c) 1991, 2001, 2002 by Oracle Corporation
##############################################################################
 
###########################################
# Shared Server
###########################################
dispatchers="(PROTOCOL=TCP) (SERVICE=erp3XDB)"
 
###########################################
# Miscellaneous
###########################################
compatible=11.2.0.0.0
diagnostic_dest=C:\app\Administrator
memory_target=3391094784
 
###########################################
# Security and Auditing
###########################################
audit_file_dest=C:\app\Administrator\admin\erp3\adump
audit_trail=db
remote_login_passwordfile=EXCLUSIVE
 
###########################################
# Database Identification
###########################################
db_domain=""
db_name=erp3
 
###########################################
# File Configuration
###########################################
control_files=("C:\app\Administrator\oradata\erp3\control01.ctl", "C:\app\Administrator\flash_recovery_area\erp3\control02.ctl")
db_recovery_file_dest=C:\app\Administrator\flash_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

6.创建监听服务
使用网络配置助手或者
修改ORACLE_HOME下的network/admin/tnsnames.ora
ERP3 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = HZW27LWPQF3PVI0)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = erp3)
    )
  )

7.使用oradim命令创建实例
oradim -NEW -SID sid -STARTMODE MANUAL -PFILE pfile
oradim -NEW -SID sid -STARTMODE AUTO -PFILE pfile
使自动启动
ORADIM -EDIT -SID sid -STARTMODE AUTO -SRVCSTART SYSTEM [-SPFILE]
删除
oradim -delete -sid orcl

8.连接到实例
命令行下进入sqlplus
sqlplus /nolog

CONNECT SYS AS SYSDBA

startup nomount;
select instance_name from v$instance; 

9.产生spfile
sqlplus中执行如下
CREATE SPFILE FROM PFILE;

10.创建数据库 执行如下脚本

CREATE DATABASE erp3
   USER SYS IDENTIFIED BY 123456
   USER SYSTEM IDENTIFIED BY 123456
   LOGFILE GROUP 1 ('C:/app/Administrator/oradata/erp3/redo01a.log','C:/app/Administrator/oradata/erp3/redo01b.log') SIZE 100M BLOCKSIZE 512,
           GROUP 2 ('C:/app/Administrator/oradata/erp3/redo02a.log','C:/app/Administrator/oradata/erp3/redo02b.log') SIZE 100M BLOCKSIZE 512,
           GROUP 3 ('C:/app/Administrator/oradata/erp3/redo03a.log','C:/app/Administrator/oradata/erp3/redo03b.log') SIZE 100M BLOCKSIZE 512
   MAXLOGFILES 32
   MAXLOGMEMBERS 5
   MAXLOGHISTORY 1
   MAXDATAFILES 100
   CHARACTER SET AL32UTF8
   NATIONAL CHARACTER SET AL16UTF16
   EXTENT MANAGEMENT LOCAL
   DATAFILE 'C:/app/Administrator/oradata/erp3/system01.dbf' SIZE 325M REUSE
   SYSAUX DATAFILE 'C:/app/Administrator/oradata/erp3/sysaux01.dbf' SIZE 325M REUSE
   DEFAULT TABLESPACE users
      DATAFILE 'C:/app/Administrator/oradata/erp3/users01.dbf'
      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
   DEFAULT TEMPORARY TABLESPACE tempts1
      TEMPFILE 'C:/app/Administrator/oradata/erp3/temp01.dbf'
      SIZE 20M REUSE
   UNDO TABLESPACE undotbs1
      DATAFILE 'C:/app/Administrator/oradata/erp3/undotbs01.dbf'
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

11.执行脚本sqlplus下执行如下脚本
@C:\app\Administrator\product\11.2.0\dbhome_1\RDBMS\ADMIN\catalog.sql

@C:\app\Administrator\product\11.2.0\dbhome_1\RDBMS\ADMIN\catproc.sql

 
 
 
 


 

你可能感兴趣的:(windows7下oracle命令行手动创建数据库)