系统环境: 1、操作系统:Windows2000 Server2、数据库: Oracle8i R2 (8.1.6) for NT 企业版/Oracle 9i for NT 企业版3、安装路径:D:\ORACLE步骤:1、手工创建相关目录2、手工创建初始化参数文件3、通过oradim创建一个ORACLE服务4、创建数据库5、创建数据库数据文件,执行脚本6、创建数据字典,运行
手工创建数据库完整步骤系统环境操作系统:Windows2000 Server 数据库:Oracle 9i安装路径:C:\Oracle1、手工创建相关目录C:\Oracle\admin\webC:\Oracle\admin\web\bdumpC:\Oracle\admin\web\udumpC:\Oracle\admin\web\cdumpC:\Oracle\admin\web\pfileC:\Oracle\admin\web\createC:\Oracle\oradata\webC:\Oracle\oradata\web\archive2、手工创建初始化参数文件c:\oracle\admin\web\pfile\init.ora,内容可以copy别的实例init.ora文件后修改。3、手工创建initweb.ora文件,内容::ifile=c:\oracle\admin\web\pfile\init.ora4、使用orapwd.exe命令,创建口令文件pwdweb.ora,命令格式如下: orapwd.exe file=c:\oracle\ora90\database\pwdweb.ora password=ltjsb entries=55、通过oradim.exe命令,在服务里生成一个新的实例管理服务,启动方式为手工set ORACLE_SID=webC:\oracle\ora90\bin\oradim -new -sid WEB -startmode m-pfile C:\oracle\ora90\database\initweb.ora6、创建数据库,执行createdb.sql脚本命令, SQL>sqlplus /nologSQL>connect SYS/change_on_install as SYSDBASQL>@Createdb.sqlCreatedb.sql脚本内容如下:set echo onspool C:\oracle\admin\mydb\create\CreateDB.logstartup nomount pfile="C:\oracle\admin\web\pfile\init.ora";CREATE DATABASE webMAXINSTANCES 1MAXLOGHISTORY 1MAXLOGFILES 5MAXLOGMEMBERS 5MAXDATAFILES 100DATAFILE 'C:\oracle\oradata\web\system01.dbf' SIZE 325M REUSE AUTOEXTEND ONNEXT 10240K MAXSIZE UNLIMITEDUNDO TABLESPACE "UNDOTBS" DATAFILE'C:\oracle\oradata\web\undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ONNEXT 5120K MAXSIZE UNLIMITEDCHARACTER SET ZHS16GBKNATIONAL CHARACTER SET AL16UTF16LOGFILE GROUP 1 ('C:\oracle\oradata\web\redo01.log') SIZE 100M,GROUP 2 ('C:\oracle\oradata\web\redo02.log') SIZE 100M,GROUP 3 ('C:\oracle\oradata\web\redo03.log') SIZE 100M;spool offexit;注:创建数据库时,执行sql.bsqj脚本命令,此脚本命令创建如下内容: 创建控制文件和联机日志文件 创建数据库系统表空system 在system表空间上创建system系统回滚段 创建sys和system账号 创建基表和簇 创建数据字典表、索引和序列 创建相关角色权限7、创建数据库数据文件,执行脚本createfiles.sqlSQL>sqlplus /nologSQL> connect SYS/change_on_install as SYSDBASQL>@createfiles.sqlCreatefiles.sql脚本内容如下:set echo onspool C:\oracle\admin\mydb\create\CreateDBFiles.logCREATE TABLESPACE "INDX" LOGGING DATAFILE'C:\oracle\oradata\web\indx01.dbf' SIZE 25M REUSE AUTOEXTEND ONNEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;CREATE TEMPORARY TABLESPACE "TEMP" TEMPFILE'C:\oracle\oradata\web\temp01.dbf' SIZE 40M REUSE AUTOEXTEND ONNEXT 640K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;ALTER DATABASE DEFAULT TEMPORARY TABLESPACE "TEMP";CREATE TABLESPACE "TOOLS" LOGGING DATAFILE'C:\oracle\oradata\web\tools01.dbf' SIZE 10M REUSE AUTOEXTEND ONNEXT 320K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;CREATE TABLESPACE "USERS" LOGGING DATAFILE'C:\oracle\oradata\web\users01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280KMAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;CREATE UNDO TABLESPACE "UNDOTBS" DATAFILE'C:\oracle\oradata\web\undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ONNEXT 5120K;spool offexit;8、创建数据字典,运行createdbcatalog.sql脚本命令SQL>sqlplus /nologSQL> connect SYS/change_on_install as SYSDBASQL>@createdbcatalog.sqlCreatedbcatalog.sql脚本内容如下:set echo onspool C:\oracle\admin\mydb\create\CreateDBCatalog.log@C:\oracle\ora90\rdbms\admin\catalog.sql;@C:\oracle\ora90\rdbms\admin\catexp7.sql;@C:\oracle\ora90\rdbms\admin\catblock.sql;@C:\oracle\ora90\rdbms\admin\catproc.sql;@C:\oracle\ora90\rdbms\admin\catoctk.sql;@C:\oracle\ora90\rdbms\admin\catobtk.sql;@C:\oracle\ora90\rdbms\admin\caths.sql;@C:\oracle\ora90\rdbms\admin\owminst.plb;connect SYSTEM/manager@C:\oracle\ora90\sqlplus\admin\pupbld.sql;connect SYSTEM/managerset echo onspool C:\oracle\ora90\assistants\dbca\logs\sqlPlusHelp.log@C:\oracle\ora90\sqlplus\admin\help\hlpbld.sql helpus.sql;spool offspool offexit;9、完善数据库,创建spfile文件,将数据库实例启动服务设置成自动启动方式。SQL>sqlplus /nologSQL> connect SYS/change_on_install as SYSDBASQL> @postdbcreation.sqlPostdbcreation.sql脚本内容如下:set echo onspool C:\oracle\admin\web\create\postDBCreation.logcreate spfile='C:\oracle\ora90\database\spfileweb.ora' FROM pfile='C:\oracle\admin\web\init.ora';connect SYS/change_on_install as SYSDBAset echo onspool C:\oracle\ora90\assistants\dbca\logs\postDBCreation.logshutdown ;startup ;注:以上都设置PATH环境变量,将bin目录加入到PATH中以便于使用工具GMGRLl,sqlplus等。 ==========================================================================================系统环境: 1、操作系统:Windows2000 Server,机器内存128M2、数据库: Oracle8i R2 (8.1.6) for NT 企业版3、安装路径:D:\ORACLE建库步骤: 1、手工创建相关目录D:\Oracle\admin\testD:\Oracle\admin\test\adhocD:\Oracle\admin\test\bdumpD:\Oracle\admin\test\cdumpD:\Oracle\admin\test\createD:\Oracle\admin\test\expD:\Oracle\admin\test\pfileD:\Oracle\admin\test\udumpD:\Oracle\oradata\testD:\Oracle\oradata\test\archive2、手工创建初始化启动参数文件:D:\Oracle\admin\test\pfile\inittest.ora,内容:3、手工创建D:\Oracle\Ora81\DATABASE\inittest.ora文件, 内容:IFILE='D:\Oracle\admin\test\pfile\inittest.ora'4、使用orapwd.exe命令,创建D:\Oracle\Ora81\DATABASE\PWDtest.ora 命令:D:\Oracle\Ora81\bin\orapwdfile=D:\Oracle\Ora81\DATABASE\PWDtest.ora password=ORACLE entries=55、通过oradim.exe命令,在服务里生成一个新的实例管理服务,启动方式为手工 set ORACLE_SID=test D:\Oracle\Ora81\bin\oradim -new -sid test -startmode manual -pfile"D:\Oracle\admin\test\pfile\inittest.ora"6、生成各种数据库对象D:\>svrmgrl--创建数据库connect INTERNAL/oraclestartup nomount pfile="D:\Oracle\admin\test\pfile\inittest.ora"CREATE DATABASE testLOGFILE 'D:\Oracle\oradata\test\redo01.log' SIZE 2048K, 'D:\Oracle\oradata\test\redo02.log' SIZE 2048K, 'D:\Oracle\oradata\test\redo03.log' SIZE 2048KMAXLOGFILES 32MAXLOGMEMBERS 2MAXLOGHISTORY 1DATAFILE 'D:\Oracle\oradata\test\system01.dbf' SIZE 58M REUSEAUTOEXTEND ON NEXT 640KMAXDATAFILES 254MAXINSTANCES 1CHARACTER SET ZHS16GBKNATIONAL CHARACTER SET ZHS16GBK;控制文件、日志文件在上面语句执行时生成connect INTERNAL/oracle--修改系统表空间ALTER TABLESPACE SYSTEM DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1MAXEXTENTS UNLIMITED PCTINCREASE 50);ALTER TABLESPACE SYSTEM MINIMUM EXTENT 64K;--创建回滚表空间CREATE TABLESPACE RBS DATAFILE 'D:\Oracle\oradata\test\rbs01.dbf' SIZE 256MREUSE AUTOEXTEND ON NEXT 5120K MINIMUM EXTENT 512K DEFAULT STORAGE ( INITIAL 512K NEXT 512K MINEXTENTS8 MAXEXTENTS 4096);--创建用户表空间CREATE TABLESPACE USERS DATAFILE 'D:\Oracle\oradata\test\users01.dbf' SIZE 128MREUSE AUTOEXTEND ON NEXT 1280K MINIMUM EXTENT 128K DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS1 MAXEXTENTS 4096 PCTINCREASE 0);--创建临时表空间CREATE TABLESPACE TEMP DATAFILE 'D:\Oracle\oradata\test\temp01.dbf' SIZE 32MREUSE AUTOEXTEND ON NEXT 640K MINIMUM EXTENT 64K DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1MAXEXTENTS UNLIMITED PCTINCREASE 0) TEMPORARY;--创建工具表空间CREATE TABLESPACE TOOLS DATAFILE 'D:\Oracle\oradata\test\tools01.dbf' SIZE 64MREUSE AUTOEXTEND ON NEXT 320K MINIMUM EXTENT 32K DEFAULT STORAGE ( INITIAL 32K NEXT 32K MINEXTENTS 1MAXEXTENTS 4096 PCTINCREASE 0);--创建索引表空间CREATE TABLESPACE INDX DATAFILE 'D:\Oracle\oradata\test\indx01.dbf' SIZE 32MREUSE AUTOEXTEND ON NEXT 1280K MINIMUM EXTENT 128K DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS1 MAXEXTENTS 4096 PCTINCREASE 0);--创建回滚段CREATE PUBLIC ROLLBACK SEGMENT RBS0 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS1 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS2 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS3 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS4 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS5 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS6 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS7 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS8 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS9 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS10 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS11 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS12 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS13 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS14 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS15 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS16 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS17 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS18 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS19 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS20 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS21 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS22 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS23 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );CREATE PUBLIC ROLLBACK SEGMENT RBS24 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );--使回滚段在线ALTER ROLLBACK SEGMENT "RBS0" ONLINE;ALTER ROLLBACK SEGMENT "RBS1" ONLINE;ALTER ROLLBACK SEGMENT "RBS2" ONLINE;ALTER ROLLBACK SEGMENT "RBS3" ONLINE;ALTER ROLLBACK SEGMENT "RBS4" ONLINE;ALTER ROLLBACK SEGMENT "RBS5" ONLINE;ALTER ROLLBACK SEGMENT "RBS6" ONLINE;ALTER ROLLBACK SEGMENT "RBS7" ONLINE;ALTER ROLLBACK SEGMENT "RBS8" ONLINE;ALTER ROLLBACK SEGMENT "RBS9" ONLINE;ALTER ROLLBACK SEGMENT "RBS10" ONLINE;ALTER ROLLBACK SEGMENT "RBS11" ONLINE;ALTER ROLLBACK SEGMENT "RBS12" ONLINE;ALTER ROLLBACK SEGMENT "RBS13" ONLINE;ALTER ROLLBACK SEGMENT "RBS14" ONLINE;ALTER ROLLBACK SEGMENT "RBS15" ONLINE;ALTER ROLLBACK SEGMENT "RBS16" ONLINE;ALTER ROLLBACK SEGMENT "RBS17" ONLINE;ALTER ROLLBACK SEGMENT "RBS18" ONLINE;ALTER ROLLBACK SEGMENT "RBS19" ONLINE;ALTER ROLLBACK SEGMENT "RBS20" ONLINE;ALTER ROLLBACK SEGMENT "RBS21" ONLINE;ALTER ROLLBACK SEGMENT "RBS22" ONLINE;ALTER ROLLBACK SEGMENT "RBS23" ONLINE;ALTER ROLLBACK SEGMENT "RBS24" ONLINE;--修改sys用户的临时表空间为TEMPalter user sys temporary tablespace TEMP;--创建数据字典表@D:\Oracle\Ora81\Rdbms\admin\catalog.sql;@D:\Oracle\Ora81\Rdbms\admin\catexp7.sql@D:\Oracle\Ora81\Rdbms\admin\catproc.sql@D:\Oracle\Ora81\Rdbms\admin\caths.sqlconnect system/manager@D:\Oracle\Ora81\sqlplus\admin\pupbld.sqlconnect internal/oracle@D:\Oracle\Ora81\Rdbms\admin\catrep.sqlexit--生成SQL*Plus帮助系统sqlplus SYSTEM/manager@D:\Oracle\Ora81\sqlplus\admin\help\helpbld.sql helpus.sqlexit--修改system用户默认表空间和临时表空间svrmgrlconnect internal/oraclealter user system default tablespace TOOLS;alter user system temporary tablespace TEMP;exit7、将test实例启动服务设置成自动启动方式D:\Oracle\Ora81\bin\oradim -edit -sid test -startmode auto(完)
计算机基础教程网