Oracle 10g和11g手动建库过程

0    85    1

👉 本文共约13502个字,系统预计阅读时间或需51分钟。

前言部分

导读和注意事项

各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~:

① 10G和11g手动建库(重点)

② 各种组件安装

③ 创建Sample Schemas数据

④ 手动建库中常用脚本的解释

⑤ sqlplus中的帮助命令

本文简介

上一篇(http://blog.itpub.net/26736162/viewspace-2121930/)中最后差了手动建库的部分,今天把这个部分的内容加上。本来手动建库很早就学习过了,只是一直没有时间来整理发布,今天就趁这个机会正好整理一下,分享给大家。

小麦苗学习手动建库的动力源于之前帮网友采用dbca建库的时候报错,由于java环境的问题,dbca一直没有办法使用,无论界面还是静默都用到java,折腾了2个小时还是把java没有修复好,dbca不能用,最后想到了create database手动建库,虽然工作中很少采用但还是有一定的用途的。

手动建库简介

有时候因为环境的缘故不能使用图形界面或者不能使用dbca的静默方式来创建一个新库,那么这个时候可以考虑使用CREATE DATABASE SQL命令行来创建数据库,该方式是一种手动建库方式,使用此种命令行手动创建数据库的优点是:可以用脚本来创建数据库。 另外OCM的考试中要求我们用CREATE DATABASE来创建数据库。当然在使用脚本创建数据库时,在建立数据字典视图和安装标准的PL/SQL程序包时,必须先建立一个可以操作的数据库。

手动建库基本步骤

官方文档的步骤:

Step 1: Specify an Instance Identifier (SID)

Step 2: Ensure That the Required Environment Variables Are Set

Step 3: Choose a Database Administrator Authentication Method

Step 4: Create the Initialization Parameter File

Step 5: (Windows Only) Create an Instance

Step 6: Connect to the Instance

Step 7: Create a Server Parameter File

Step 8: Start the Instance

Step 9: Issue the CREATE DATABASE Statement

Step 10: Create Additional Tablespaces

Step 11: Run Scripts to Build Data Dictionary Views

Step 12: (Optional) Run Scripts to Install Additional Options

本人提供Oracle、MySQL、PG等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!

Step 13: Back Up the Database.

Step 14: (Optional) Enable Automatic Instance Startup

具体可以参考: http://docs.oracle.com/cd/E11882_01/server.112/e25494/create.htm

我的blog:http://blog.itpub.net/26736162/viewspace-2098211/

直接给出脚本

我们直接给出手动建库用到的脚本,至于过程小麦苗就不演示了。

11G

ORACLE用户执行 数据文件在文件系统 单实例DB

------------ 1、 确保环境变量正确

export ORACLE_SID=lhrdb

env|grep ORACLE

ORACLE_SID=lhrdb

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

------------ 2、 创建密码文件

orapwd file=$ORACLE_HOME/dbs/orapwlhrdb password=lhr force=y

------------ 3、 创建初始化参数文件和相关路径

$ORACLE_HOME/dbs/initlhrdb.ora

db_name='lhrdb'

memory_target=400437056

processes = 150

audit_file_dest='/u01/app/oracle/admin/lhrdb/adump'

audit_trail ='db'

db_block_size=8192

db_domain=''

db_create_file_dest='/u01/app/oracle/oradata'

db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

db_recovery_file_dest_size=2G

diagnostic_dest='/u01/app/oracle'

dispatchers='(PROTOCOL=TCP) (SERVICE=MYNEWDBXDB)'

open_cursors=300

remote_login_passwordfile='EXCLUSIVE'

undo_tablespace='UNDOTBS1'

control_files = '/u01/app/oracle/oradata/lhrdb/control01.ctl','/u01/app/oracle/flash_recovery_area/lhrdb/control02.ctl'

compatible ='11.2.0'

mkdir -p /u01/app/oracle/admin/lhrdb/adump

mkdir -p /u01/app/oracle/flash_recovery_area/lhrdb/

mkdir -p /u01/app/oracle/oradata/lhrdb/

------------ 4、 创建spfile,启动到nomount状态

sqlplus / as sysdba

create spfile from pfile;

startup nomount

! ps -ef|grep lhrdb

------------ 5、 创建DB

CREATE DATABASE lhrdb

USER SYS IDENTIFIED BY lhr

USER SYSTEM IDENTIFIED BY lhr

CONTROLFILE REUSE

CHARACTER SET ZHS16GBK

NATIONAL CHARACTER SET AL16UTF16

EXTENT MANAGEMENT LOCAL

ARCHIVELOG

MAXLOGFILES 192 MAXLOGMEMBERS 5 MAXLOGHISTORY 292 MAXDATAFILES 1024 MAXINSTANCES 32

LOGFILE GROUP 1('/u01/app/oracle/oradata/lhrdb/redo01a.log','/u01/app/oracle/oradata/lhrdb/redo01b.log') SIZE 50M BLOCKSIZE 512,

GROUP 2('/u01/app/oracle/oradata/lhrdb/redo02a.log','/u01/app/oracle/oradata/lhrdb/redo02b.log') SIZE 50M blocksize 512,

GROUP 3('/u01/app/oracle/oradata/lhrdb/redo03a.log','/u01/app/oracle/oradata/lhrdb/redo03b.log') SIZE 50M BLOCKSIZE 512

DATAFILE '/u01/app/oracle/oradata/lhrdb/system01.dbf' SIZE 300M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 10G

SYSAUX DATAFILE '/u01/app/oracle/oradata/lhrdb/sysaux01.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 10G

DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/app/oracle/oradata/lhrdb/temp01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 1G

UNDO TABLESPACE UNDOTBS1 DATAFILE '/u01/app/oracle/oradata/lhrdb/undotbs01.dbf'SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 1G

DEFAULT TABLESPACE USERS DATAFILE '/u01/app/oracle/oradata/lhrdb/users01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 10G

/

SPOOL /tmp/dictionary_tmp.sql

@?/rdbms/admin/catalog.sql

@?/rdbms/admin/catproc.sql

@?/rdbms/admin/catclust.sql

@?/rdbms/admin/dbmspool.sql

@?/rdbms/admin/catblock.sql

@?/rdbms/admin/caths.sql

@?/rdbms/admin/owminst.plb

@?/sqlplus/admin/plustrce.sql

@?/rdbms/admin/utlrp.sql

@?/rdbms/admin/utlsampl.sql

conn system/lhr

@?/sqlplus/admin/pupbld.sql

@?/sqlplus/admin/help/hlpbld.sql helpus.sql

SPOOL off

------ 单实例数据库添加到srvctl中

srvctl add database -d lhrdb -c single -o /u01/app/oracle/product/11.2.0/dbhome_1 -p '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilelhrdb.ora' -r primary -n lhrdb -x ZFXDESKDB2

srvctl config database -d lhrdb -a

srvctl status database -d lhrdb

srvctl start database -d lhrdb

crsctl stat res -t

------ drop database

alter database close;

alter system enable restricted session;

drop database;

ORACLE用户执行 数据文件在ASM中 单实例DB

------------ 1、 确保环境变量正确

export ORACLE_SID=lhrasm

env|grep ORACLE

ORACLE_SID=lhrasm

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

------------ 2、 创建密码文件

orapwd file=$ORACLE_HOME/dbs/orapwlhrasm password=lhr force=y

------------ 3、 创建初始化参数文件和相关路径

$ORACLE_HOME/dbs/initlhrasm.ora

db_name='lhrasm'

memory_target=400437056

processes = 150

audit_file_dest='/u01/app/oracle/admin/lhrasm/adump'

audit_trail ='db'

db_block_size=8192

db_domain=''

db_create_file_dest='+DATA'

db_recovery_file_dest='+FRA'

db_recovery_file_dest_size=2G

diagnostic_dest='/u01/app/oracle'

dispatchers='(PROTOCOL=TCP) (SERVICE=MYNEWDBXDB)'

open_cursors=300

remote_login_passwordfile='EXCLUSIVE'

undo_tablespace='UNDOTBS1'

control_files = '+DATA/lhrasm/controlfile/control01.ctl','+FRA/lhrasm/controlfile/control02.ctl'

compatible ='11.2.0'

mkdir -p /u01/app/oracle/admin/lhrasm/adump

mkdir -p /u01/app/oracle/flash_recovery_area/lhrasm/

mkdir -p /u01/app/oracle/oradata/lhrasm/

------------ 4、 创建spfile,启动到nomount状态

sqlplus / as sysdba

create spfile from pfile;

startup nomount

! ps -ef|grep lhrasm

------------ 5、 创建DB

CREATE DATABASE lhrasm

USER SYS IDENTIFIED BY lhr

USER SYSTEM IDENTIFIED BY lhr

CONTROLFILE REUSE

CHARACTER SET ZHS16GBK

NATIONAL CHARACTER SET AL16UTF16

EXTENT MANAGEMENT LOCAL

ARCHIVELOG

MAXLOGFILES 192 MAXLOGMEMBERS 5 MAXLOGHISTORY 292 MAXDATAFILES 1024 MAXINSTANCES 32

LOGFILE GROUP 1('+DATA','+DATA') SIZE 50M BLOCKSIZE 512,

GROUP 2('+DATA','+DATA') SIZE 50M blocksize 512,

GROUP 3('+DATA','+DATA') SIZE 50M BLOCKSIZE 512

DATAFILE '+DATA' SIZE 300M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 10G

SYSAUX DATAFILE '+DATA' SIZE 100M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 10G

SET DEFAULT bigfile TABLESPACE

DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '+DATA' SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 1G

UNDO TABLESPACE UNDOTBS1 DATAFILE '+DATA'SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 1G

DEFAULT TABLESPACE USERS DATAFILE '+DATA' SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 1G

;

/* --------- BIGFILE

CREATE DATABASE lhrasm

USER SYS IDENTIFIED BY lhr

USER SYSTEM IDENTIFIED BY lhr

CONTROLFILE REUSE

EXTENT MANAGEMENT LOCAL

SET DEFAULT bigfile TABLESPACE

DEFAULT TEMPORARY TABLESPACE TEMP

UNDO TABLESPACE UNDOTBS1

DEFAULT TABLESPACE USERS

;

*/

SPOOL /tmp/dictionary_tmp.sql

@?/rdbms/admin/catalog.sql

@?/rdbms/admin/catproc.sql

@?/rdbms/admin/catclust.sql

@?/rdbms/admin/dbmspool.sql

@?/rdbms/admin/catblock.sql

@?/rdbms/admin/caths.sql

@?/rdbms/admin/owminst.plb

@?/sqlplus/admin/plustrce.sql

@?/rdbms/admin/utlrp.sql

@?/rdbms/admin/utlsampl.sql

conn system/lhr

@?/sqlplus/admin/pupbld.sql

@?/sqlplus/admin/help/hlpbld.sql helpus.sql

SPOOL off

------ 单实例数据库添加到srvctl中

srvctl add database -d lhrasm -c single -o /u01/app/oracle/product/11.2.0/dbhome_1 -p '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilelhrasm.ora' -r primary -n lhrasm -x ZFXDESKDB2

srvctl config database -d lhrasm -a

srvctl status database -d lhrasm

srvctl start database -d lhrasm

crsctl stat res -t

------ drop database

alter database close;

alter system enable restricted session;

drop database;

11G rac asm

---- 思路:先创建单实例DB然后再转换为RAC DB

export ORACLE_SID=raclhr1

env|grep ORACLE

ORACLE_SID=raclhr

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

------------ 2、 2个节点都 创建密码文件

orapwd file=$ORACLE_HOME/dbs/orapwraclhr1 password=lhr force=y

orapwd file=$ORACLE_HOME/dbs/orapwraclhr2 password=lhr force=y

------------ 3、 创建初始化参数文件和相关路径

--- 节点一配置:

$ORACLE_HOME/dbs/initraclhr1.ora

*.db_name='raclhr'

*.memory_target=400437056

*.processes = 150

*.open_cursors=300

*.audit_file_dest='/u01/app/oracle/admin/raclhr/adump'

*.audit_trail ='db'

*.db_block_size=8192

*.db_domain=''

*.db_create_file_dest='+DATA'

*.db_recovery_file_dest='+FRA'

*.db_recovery_file_dest_size=2G

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=MYNEWDBXDB)'

*.control_files = '+DATA/raclhr/controlfile/control01.ctl','+FRA/raclhr/controlfile/control02.ctl'

*.remote_login_passwordfile='EXCLUSIVE'

---2个节点都创建路径

mkdir -p /u01/app/oracle/admin/raclhr/adump

mkdir -p /u01/app/oracle/flash_recovery_area/raclhr/

mkdir -p /u01/app/oracle/oradata/raclhr/

--- 节点一执行

su - grid

asmcmd

cd +DATA

mkdir raclhr

cd raclhr

mkdir PARAMETERFILE

su - oracle

sqlplus / as sysdba

create spfile='+DATA/raclhr/PARAMETERFILE/spfileraclhr.ora' from pfile;

---2个节点都执行 创建初始化参数文件执行ASM磁盘里的SPFILE

cp $ORACLE_HOME/dbs/initraclhr1.ora $ORACLE_HOME/dbs/initraclhr1.ora_bk

echo "spfile='+DATA/raclhr/PARAMETERFILE/spfileraclhr.ora'" > $ORACLE_HOME/dbs/initraclhr1.ora

echo "spfile='+DATA/raclhr/PARAMETERFILE/spfileraclhr.ora'" > $ORACLE_HOME/dbs/initraclhr2.ora

------------ 4、节点一启动到nomount状态

startup nomount

! ps -ef|grep raclhr

show parameter spfile

------------ 5、 创建DB

CREATE DATABASE raclhr

USER SYS IDENTIFIED BY lhr

USER SYSTEM IDENTIFIED BY lhr

CONTROLFILE REUSE

CHARACTER SET ZHS16GBK

NATIONAL CHARACTER SET AL16UTF16

EXTENT MANAGEMENT LOCAL

ARCHIVELOG

MAXLOGFILES 192 MAXLOGMEMBERS 5 MAXLOGHISTORY 292 MAXDATAFILES 1024 MAXINSTANCES 32

LOGFILE GROUP 1('+DATA','+DATA') SIZE 50M BLOCKSIZE 512,

GROUP 2('+DATA','+DATA') SIZE 50M blocksize 512,

GROUP 3('+DATA','+DATA') SIZE 50M BLOCKSIZE 512

DATAFILE '+DATA' SIZE 300M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 10G

SYSAUX DATAFILE '+DATA' SIZE 100M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 10G

SET DEFAULT bigfile TABLESPACE

DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '+DATA' SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 1G

UNDO TABLESPACE UNDOTBS1 DATAFILE '+DATA'SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 1G

DEFAULT TABLESPACE USERS DATAFILE '+DATA' SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 10G

;

/* --------- BIGFILE

CREATE DATABASE raclhr

USER SYS IDENTIFIED BY lhr

USER SYSTEM IDENTIFIED BY lhr

CONTROLFILE REUSE

EXTENT MANAGEMENT LOCAL

SET DEFAULT bigfile TABLESPACE

DEFAULT TEMPORARY TABLESPACE TEMP

UNDO TABLESPACE UNDOTBS1

DEFAULT TABLESPACE USERS

;

*/

------------ 6、 修改rac需要的内容

create undo tablespace UNDOTBS2 datafile '+DATA' size 50M reuse autoextend off;

alter database add logfile thread 2 group 4 ('+DATA','+FRA') SIZE 50M BLOCKSIZE 512;

alter database add logfile thread 2 group 5 ('+DATA','+FRA') SIZE 50M BLOCKSIZE 512;

alter database add logfile thread 2 group 6 ('+DATA','+FRA') SIZE 50M BLOCKSIZE 512;

select * from v$log;

ALTER SYSTEM SET cluster_database=true scope=spfile sid='*';

ALTER SYSTEM SET instance_number=1 scope=spfile sid='raclhr1';

ALTER SYSTEM SET instance_number=2 scope=spfile sid='raclhr2';

ALTER SYSTEM SET thread=1 scope=spfile sid='raclhr1';

ALTER SYSTEM SET thread=2 scope=spfile sid='raclhr2';

ALTER SYSTEM SET undo_tablespace='UNDOTBS1' scope=spfile sid='raclhr1';

ALTER SYSTEM SET undo_tablespace='UNDOTBS2' scope=spfile sid='raclhr2';

alter database enable public thread 2;

shutdown immediate

------------ 7、 启动2个节点

------ rac 数据库添加到srvctl中

srvctl add database -d raclhr -c rac -o /oracle/app/oracle/product/11.2.0/db -p '+DATA/raclhr/PARAMETERFILE/spfileraclhr.ora' -r primary -n raclhr

srvctl config database -d raclhr -a

srvctl add instance -d raclhr -i raclhr1 -n ZFXDESKDB1

srvctl add instance -d raclhr -i raclhr2 -n ZFXDESKDB2

srvctl status database -d raclhr

srvctl stop db -d raclhr

srvctl start db -d raclhr

srvctl status database -d raclhr

crsctl stat res -t

------------ 8、 编译数据字典脚本

SPOOL /tmp/dictionary_tmp.sql

@?/rdbms/admin/catalog.sql

@?/rdbms/admin/catproc.sql

@?/rdbms/admin/catclust.sql

@?/rdbms/admin/dbmspool.sql

@?/rdbms/admin/catblock.sql

@?/rdbms/admin/caths.sql

@?/rdbms/admin/owminst.plb

@?/sqlplus/admin/plustrce.sql

@?/rdbms/admin/utlrp.sql

@?/rdbms/admin/utlsampl.sql

conn system/lhr

@?/sqlplus/admin/pupbld.sql

@?/sqlplus/admin/help/hlpbld.sql helpus.sql

SPOOL off

------ drop database

alter system set cluster_database=false scope=spfile;

! srvctl stop db -d raclhr

startup force mount restrict;

drop database;

10G

export ORACLE_SID=lhrdb

orapwd file=$ORACLE_HOME/dbs/orapwlhrdb password=lhr force=y

vi $ORACLE_HOME/dbs/initlhrdb.ora

db_name=lhrdb

processes=150

max_dump_file_size=10240

global_names=TRUE

control_files=('/u01/app/oracle/oradata/lhrdb/control01.ora','/u01/app/oracle/oradata/lhrdb/control02.ora')

sga_target=400m

undo_management='AUTO'

undo_tablespace='UNDOTBS1'

mkdir -p $ORACLE_BASE/oradata/lhrdb

mkdir -p $ORACLE_BASE/lhrdb/adump

mkdir -p $ORACLE_BASE/lhrdb/bdump

mkdir -p $ORACLE_BASE/lhrdb/cdump

mkdir -p $ORACLE_BASE/lhrdb/ddump

mkdir -p $ORACLE_BASE/lhrdb/udump

sqlplus / as sysdba

create spfile from pfile;

startup nomount;

CREATE DATABASE lhrdb

USER SYS IDENTIFIED BY lhr

USER SYSTEM IDENTIFIED BY lhr

CONTROLFILE REUSE

CHARACTER SET ZHS16GBK

NATIONAL CHARACTER SET AL16UTF16

EXTENT MANAGEMENT LOCAL

ARCHIVELOG

MAXLOGFILES 24 MAXLOGMEMBERS 5 MAXLOGHISTORY 292 MAXDATAFILES 1024 MAXINSTANCES 12

LOGFILE GROUP 1 ('/u01/app/oracle/oradata/lhrdb/redo01.log') SIZE 50M,

GROUP 2 ('/u01/app/oracle/oradata/lhrdb/redo02.log') SIZE 50M,

GROUP 3 ('/u01/app/oracle/oradata/lhrdb/redo03.log') SIZE 50M

DATAFILE '/u01/app/oracle/oradata/lhrdb/system01.dbf' SIZE 300M REUSE

SYSAUX DATAFILE '/u01/app/oracle/oradata/lhrdb/sysaux01.dbf' SIZE 100M REUSE

DEFAULT TEMPORARY TABLESPACE temp TEMPFILE '/u01/app/oracle/oradata/lhrdb/temp01.dbf' SIZE 20M REUSE

UNDO TABLESPACE undotbs1 DATAFILE '/u01/app/oracle/oradata/lhrdb/undotbs01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 1G ;

conn / as sysdba

SPOOL /tmp/dictionary_tmp.sql

@?/rdbms/admin/catalog.sql

@?/rdbms/admin/catproc.sql

@?/rdbms/admin/catclust.sql

@?/rdbms/admin/dbmspool.sql

@?/rdbms/admin/catblock.sql

@?/rdbms/admin/caths.sql

@?/rdbms/admin/owminst.plb

@?/sqlplus/admin/plustrce.sql

@?/rdbms/admin/utlrp.sql

@?/rdbms/admin/utlsampl.sql

conn system/lhr

@?/sqlplus/admin/pupbld.sql

@?/sqlplus/admin/help/hlpbld.sql helpus.sql

SPOOL off

创建bigfile的db报错

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-01501: CREATE DATABASE failed

ORA-01519: error while processing file '?/rdbms/admin/dtxnspc.bsq' near line 20

ORA-00604: error occurred at recursive SQL level 1

ORA-32772: BIGFILE is invalid option for this type of tablespace

Process ID: 12451948

Session ID: 156 Serial number: 3

--------- 解决办法:SET DEFAULT bigfile TABLESPACE 位置不对,应该如下:

/* ---------BIGFILE

CREATE DATABASE lhrasm

USER SYS IDENTIFIED BY lhr

USER SYSTEM IDENTIFIED BY lhr

CONTROLFILE REUSE

CONTROLFILE REUSE

CHARACTER SET ZHS16GBK

NATIONAL CHARACTER SET AL16UTF16

EXTENT MANAGEMENT LOCAL

ARCHIVELOG

MAXLOGFILES 192 MAXLOGMEMBERS 5 MAXLOGHISTORY 292 MAXDATAFILES 1024 MAXINSTANCES 32

LOGFILE GROUP 1('+DATA','+DATA') SIZE 50M BLOCKSIZE 512,

GROUP 2('+DATA','+DATA') SIZE 50M blocksize 512,

GROUP 3('+DATA','+DATA') SIZE 50M BLOCKSIZE 512

DATAFILE '+DATA' SIZE 300M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED

SYSAUX DATAFILE '+DATA' SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED

SET DEFAULT bigfile TABLESPACE

DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '+DATA' SIZE 20M REUSE AUTOEXTEND OFF

UNDO TABLESPACE UNDOTBS1 DATAFILE '+DATA'SIZE 50M REUSE AUTOEXTEND OFF

DEFAULT TABLESPACE USERS DATAFILE '+DATA' SIZE 500M REUSE AUTOEXTEND OFF

;

CREATE DATABASE lhrasm

USER SYS IDENTIFIED BY lhr

USER SYSTEM IDENTIFIED BY lhr

CONTROLFILE REUSE

EXTENT MANAGEMENT LOCAL

SET DEFAULT bigfile TABLESPACE

DEFAULT TEMPORARY TABLESPACE TEMP

UNDO TABLESPACE UNDOTBS1

DEFAULT TABLESPACE USERS

;

*/

手动建库中的组件安装

------ 安装JVM

@?/javavm/install/initjvm.sql;

@?/xdk/admin/initxml.sql;

@?/xdk/admin/xmlja.sql;

@?/rdbms/admin/catjava.sql;

-- 安装XMLDB

@?/rdbms/admin/catqm.sql oracle SYSAUX TEMP YES

@?/rdbms/admin/catxdbj.sql;

其它组件安装可以参考:http://blog.itpub.net/26736162/viewspace-1562441/

如何安装Sample Schemas

dbca静默安装中有个参数是sampleSchema我们若设置为true,则安装后数据库中有EXAMPLE表空间,有HR,OE,PM,SH,IX用户,大约占用350M的空间,若设置为false,则后续可以根据以下文档来安装。

【OH】 Database Sample Schemas -- Installation and Descriptionshttp://blog.itpub.net/26736162/viewspace-2098222/

手动建库中常用脚本的解释

更多的数据字典脚本说明可以参考:【OH】常用数据字典脚本说明 SQL Scripts :http://blog.itpub.net/26736162/viewspace-2098205/

Script NameNeeded ForRun ByDescription
catalog.sqlAll databasesSYSCreates the data dictionary and public synonyms for many of its views Grants PUBLIC access to the synonyms
catproc.sqlAll databasesSYSRuns all scripts required for, or used with, PL/SQL
catclust.sqlReal Application ClustersSYSCreates Real Application Clusters data dictionary views
catblock.sqlPerformance managementSYSCreates views that can dynamically display lock dependency graphs
dbmspool.sqlPerformance managementSYS or SYSDBAEnables DBA to lock PL/SQL packages, SQL statements, and triggers into the shared pool
caths.sqlHeterogeneous ServicesSYSInstalls packages for administering heterogeneous services
@?/rdbms/admin/owminst.plbsys创建WMSYS用户
@?/sqlplus/admin/pupbld.sqlsystem解决PRODUCT_USER_PROFILE问题
@?/sqlplus/admin/plustrce.sqlsys普通用户set autot on的权限
@?/sqlplus/admin/help/hlpbld.sql helpus.sqlsystemsqlplus的帮助文档

关于sqlplus的帮助命令

手动建库最后有个脚本:@?/sqlplus/admin/help/hlpbld.sql helpus.sql是用来生成sqlpuls的帮助命令的,我们演示如下:

ZFXDESKDB1:oracle:/oracle>cd $ORACLE_HOME/sqlplus/admin/help

total 168

-rw-r--r-- 1 oracle dba 265 Feb 16 2003 helpbld.sql

-rw-r--r-- 1 oracle dba 366 Jan 03 2011 helpdrop.sql

-rw-r--r-- 1 oracle dba 71817 Aug 16 2012 helpus.sql

-rw-r--r-- 1 oracle dba 2154 Jan 03 2011 hlpbld.sql

ZFXDESKDB1:oracle:/oracle/app/oracle/product/11.2.0/db/sqlplus/admin/help>more helpbld.sql

--

-- Copyright (c) Oracle Corporation 2003. All Rights Reserved.

--

-- NAME

-- helpbld.sql

--

-- DESCRIPTION

-- Invoke and execute the script to loads the SQL*Plus HELP system and

-- upon completion, exit the SQL*Plus connection

--

@@&1/hlpbld.sql &2

exit

ZFXDESKDB1:oracle:/oracle/app/oracle/product/11.2.0/db/sqlplus/admin/help>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 13 09:54:19 2016

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

SYS@omflhr> ? set

SP2-0171: HELP system not available.

SYS@omflhr> @?/sqlplus/admin/help/hlpbld.sql helpus.sql

PL/SQL procedure successfully completed.

Table created.

Grant succeeded.

。。。。。。。。。。。。。。。。。。。。。。。。。

Commit complete.

PL/SQL procedure successfully completed.

SYS@omflhr> ? set

SET

---

Sets a system variable to alter the SQL*Plus environment settings

for your current session. For example, to:

- set the display width for data

- customize HTML formatting

- enable or disable printing of column headings

- set the number of lines per page

SET system_variable value

where system_variable and value represent one of the following clauses:

APPI[NFO]{OFF|ON|text} NEWP[AGE] {1|n|NONE}

ARRAY[SIZE] {15|n} NULL text

AUTO[COMMIT] {OFF|ON|IMM[EDIATE]|n} NUMF[ORMAT] format

AUTOP[RINT] {OFF|ON} NUM[WIDTH] {10|n}

AUTORECOVERY {OFF|ON} PAGES[IZE] {14|n}

AUTOT[RACE] {OFF|ON|TRACE[ONLY]} PAU[SE] {OFF|ON|text}

[EXP[LAIN]] [STAT[ISTICS]] RECSEP {WR[APPED]|EA[CH]|OFF}

BLO[CKTERMINATOR] {.|c|ON|OFF} RECSEPCHAR {_|c}

CMDS[EP] {;|c|OFF|ON} SERVEROUT[PUT] {ON|OFF}

COLSEP {_|text} [SIZE {n | UNLIMITED}]

CON[CAT] {.|c|ON|OFF} [FOR[MAT] {WRA[PPED] |

COPYC[OMMIT] {0|n} WOR[D_WRAPPED] |

COPYTYPECHECK {ON|OFF} TRU[NCATED]}]

DEF[INE] {&|c|ON|OFF} SHIFT[INOUT] {VIS[IBLE] |

DESCRIBE [DEPTH {1|n|ALL}] INV[ISIBLE]}

[LINENUM {OFF|ON}] [INDENT {OFF|ON}] SHOW[MODE] {OFF|ON}

ECHO {OFF|ON} SQLBL[ANKLINES] {OFF|ON}

EDITF[ILE] file_name[.ext] SQLC[ASE] {MIX[ED] |

EMB[EDDED] {OFF|ON} LO[WER] | UP[PER]}

ERRORL[OGGING] {ON|OFF} SQLCO[NTINUE] {> | text}

[TABLE [schema.]tablename] SQLN[UMBER] {ON|OFF}

[TRUNCATE] [IDENTIFIER identifier] SQLPLUSCOMPAT[IBILITY] {x.y[.z]}

ESC[APE] {\|c|OFF|ON} SQLPRE[FIX] {#|c}

ESCCHAR {@|?|%|$|OFF} SQLP[ROMPT] {SQL>|text}

EXITC[OMMIT] {ON|OFF} SQLT[ERMINATOR] {;|c|ON|OFF}

FEED[BACK] {6|n|ON|OFF} SUF[FIX] {SQL|text}

FLAGGER {OFF|ENTRY|INTERMED[IATE]|FULL} TAB {ON|OFF}

FLU[SH] {ON|OFF} TERM[OUT] {ON|OFF}

HEA[DING] {ON|OFF} TI[ME] {OFF|ON}

HEADS[EP] {||c|ON|OFF} TIMI[NG] {OFF|ON}

INSTANCE [instance_path|LOCAL] TRIM[OUT] {ON|OFF}

LIN[ESIZE] {80|n} TRIMS[POOL] {OFF|ON}

LOBOF[FSET] {1|n} UND[ERLINE] {-|c|ON|OFF}

LOGSOURCE [pathname] VER[IFY] {ON|OFF}

LONG {80|n} WRA[P] {ON|OFF}

LONGC[HUNKSIZE] {80|n} XQUERY {BASEURI text|

MARK[UP] HTML [OFF|ON] ORDERING{UNORDERED|

[HEAD text] [BODY text] [TABLE text] ORDERED|DEFAULT}|

[ENTMAP {ON|OFF}] NODE{BYVALUE|BYREFERENCE|

[SPOOL {OFF|ON}] DEFAULT}|

[PRE[FORMAT] {OFF|ON}] CONTEXT text}

SYS@omflhr>

SYS@omflhr> ? index

Enter Help [topic] for help.

@ COPY PAUSE SHUTDOWN

@@ DEFINE PRINT SPOOL

/ DEL PROMPT SQLPLUS

ACCEPT DESCRIBE QUIT START

APPEND DISCONNECT RECOVER STARTUP

ARCHIVE LOG EDIT REMARK STORE

ATTRIBUTE EXECUTE REPFOOTER TIMING

BREAK EXIT REPHEADER TTITLE

BTITLE GET RESERVED WORDS (SQL) UNDEFINE

CHANGE HELP RESERVED WORDS (PL/SQL) VARIABLE

CLEAR HOST RUN WHENEVER OSERROR

COLUMN INPUT SAVE WHENEVER SQLERROR

COMPUTE LIST SET XQUERY

CONNECT PASSWORD SHOW

SYS@omflhr>

标签:

头像

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

1 × 3 =

 

嘿,我是小麦,需要帮助随时找我哦
  • 18509239930
  • 个人微信

  • 麦老师QQ聊天
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部
返回顶部