Home  >  Article  >  Database  >  Oracle-XE手工创建数据库

Oracle-XE手工创建数据库

WBOY
WBOYOriginal
2016-06-07 17:12:441484browse

先是用Oracle-xe创建数据库(用root)。rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm完成之后会创建oracle.dba。基本的配置:

先是用Oracle-xe创建数据库(用root)。
rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm
完成之后会创建oracle.dba。
基本的配置:
/etc/init.d/oracle-xe configure

这时就可以su - oracle
配置环境变量。
重点是你的sid
cat .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export LANG=zh_CN.UTF-8
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export ORACLE_BASE=/usr/lib/oracle/xe/app/oracle
export ORACLE_SID=xxxxxxxxxx
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"


修改初始化文件
cat /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/dbs/init$ORACLE_SID.ora
aq_tm_processes=0
audit_file_dest=$ORACLE_BASE/admin/$ORACLE_SID/adump
background_dump_dest=$ORACLE_BASE/admin/$ORACLE_SID/bdump
compatible=10.2.0.1.0
control_files=$ORACLE_BASE/oradata/$ORACLE_SID/control01.ctl, $ORACLE_BASE/oradata/$ORACLE_SID/
control02.ctl, $ORACLE_BASE/oradata/$ORACLE_SID/control03.ctl
core_dump_dest=$ORACLE_BASE/admin/$ORACLE_SID/cdump
db_block_size=8192
db_domain=""
db_file_multiblock_read_count=16
db_name=$ORACLE_SID
instance_name=$ORACLE_SID
dispatchers="(PROTOCOL=TCP) (SERVICE=$ORACLE_SIDXDB)"
job_queue_processes=10
nls_length_semantics=BYTE
open_cursors=300
pga_aggregate_target=94371840
processes=150
remote_login_passwordfile=EXCLUSIVE
resource_manager_plan=""
sessions=170
sga_target=285212672
undo_management=AUTO
undo_retention=900
undo_tablespace=UNDOTBS1
user_dump_dest=$ORACLE_BASE/admin/$ORACLE_SID/udump


###有了这个配置,在sqlplus里面startup的时候就会把系统日志写到$ORACLE_BASE/admin/$ORACLE_SID/bdump 。


创建必要的目录(可以参考/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/):XE.sh
mkdir -p /usr/lib/oracle/xe/app/oracle/admin/$ORACLE_SID/adump
mkdir -p /usr/lib/oracle/xe/app/oracle/admin/$ORACLE_SID/bdump
mkdir -p /usr/lib/oracle/xe/app/oracle/admin/$ORACLE_SID/cdump
mkdir -p /usr/lib/oracle/xe/app/oracle/admin/$ORACLE_SID/dpdump
mkdir -p /usr/lib/oracle/xe/app/oracle/admin/$ORACLE_SID/pfile
mkdir -p /usr/lib/oracle/xe/app/oracle/admin/$ORACLE_SID/udump
mkdir -p /usr/lib/oracle/xe/app/oracle/admin/cfgtoollogs/dbca/$ORACLE_SID
mkdir -p /usr/lib/oracle/xe/app/oracle/admin/$ORACLE_SID/dbs
mkdir -p /usr/lib/oracle/xe/app/oracle/flash_recovery_area
mkdir -p /usr/lib/oracle/xe/oradata/$ORACLE_SID
mkdir -p /usr/lib/oracle/xe/app/oracle/oradata/$ORACLE_SID/


创建建库用的sql脚本:
cat createdb.sql
CREATE DATABASE ctetl
  MAXINSTANCES 1
  MAXLOGHISTORY 1
  MAXLOGFILES 5
  MAXLOGMEMBERS 5
  MAXDATAFILES 100
  DATAFILE '/usr/lib/oracle/xe/app/oracle/oradata/ctetl/system01.dbf' size 50M  reuse autoextend on next 1m maxsize unlimited extent management local
sysaux datafile '/usr/lib/oracle/xe/app/oracle/oradata/ctetl/sysaux01.dbf' size 100m
  UNDO TABLESPACE UNDOTBS DATAFILE '/usr/lib/oracle/xe/app/oracle/oradata/ctetl/undotbs01.dbf' size 50M
  AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED 
   DEFAULT TEMPORARY TABLESPACE tempts  TEMPFILE '/usr/lib/oracle/xe/app/oracle/oradata/ctetl/temp01.dbf' size 50M
  CHARACTER SET US7ASCII 
  NATIONAL CHARACTER SET AL16UTF16 
  LOGFILE GROUP 1 ('/usr/lib/oracle/xe/app/oracle/oradata/ctetl/redo01.log') size 100M,
  GROUP 2 ('/usr/lib/oracle/xe/app/oracle/oradata/ctetl/redo02.log') size 100M,
  GROUP 3 ('/usr/lib/oracle/xe/app/oracle/oradata/ctetl/redo03.log') size 100M;


现在就是创建数据库了。
###注意从装好rpm包到现在使用的都应该是oracle用户。
sqlplus "/as sysdba"
SQL> startup nomount
SQL> @/usr/lib/oracle/xe/createdb.sql
SQL> create user USER identified by  PASSWD default tablespace users;
SQL> grant resource,connect,dba to  ctetl;
@/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/admin/catalog.sql
@/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/admin/catproc.sql

更多Oracle相关信息见Oracle 专题页面 ?tid=12

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn