新建Oracle数据库三种方法:
1.通过运行Oracle Database Configuration Assistant 创建配置或删除数据库(也可在命令行下输入dbca);
2.用命令行的方式建立数据库
3.通过运行自定义的批处理脚本(或create_ORACLE_SID.bat(create_ORACLE_SID.sql))来创建配置或删除数据库
详述:
1.通过运行Oracle Database Configuration Assistant 创建配置或删除数据库;
优点:GUI方法使用方便;
缺点:不过创建过程有些慢;
2.用命令行的方式建立数据库
CONNECT / AS SYSDBA
STARTUP PFILE= 'C:oracleadmininit_testorcl.ora' NOMOUNT;
CREATE DATABASE testOrcl DATAFILE '/u02/oracle/testOrcl/system01.dbf' SIZE 100M
LOGFILE GROUP1 ('/u01/oracle/testOrcl/redo1a.log',
'/u02/oracle/testOrcl/redo1b.log') SIZE 500K,
GROUP2 ('/u01/oracle/testOrcl/redo1a.log',
'/u02/oracle/testOrcl/redo1b.log') SIZE 500K
CHARACTER SET ZHS16CGB231280;
--将数据库直接从未建置状态转换到打开状态
ALTER DATABASE OPEN;
--删除数据库(Dropping a Database)
SPOOL C:DROP_DATABASE.BAT
SELECT 'DEL '||NAME 删除数据库相关数据文件 FROM V$DATAFILE;
SELECT 'DEL '||MEMBER 删除数据重构日志文件 FROM V$LOGFILE;
SPOOL OFF;
优点:可以熟悉创建指令,创建原理;
缺点:配置简单,要求熟记命令行指令;
3.通过运行自定义的批处理或SQL脚本(create_ORACLE_SID.bat或create_ORACLE_SID.sql)来创建
--create_ORACLE_SID.bat
set ORACLE_SID= ORACLE_SID.
del C:ORACLE8IdatabasepwdORACL
C:ORACLE8Ibinoradim -new -sid ORACLE_SID. -intpwd oracle -startmode manual
-pfile C:ORACLE8IadminORACLE_SIDpfileinit.ora
C:ORACLE8Ibinsvrmgrl @C:WINNTProfilesAdministrat
C:ORACLE8Ibinsvrmgrl @C:WINNTProfilesAdministrat
C:ORACLE8Ibinoradim -edit -sid ORACLE_SID -startmode auto
--ORACLE_SIDrun.sql
spool C:ORACLE8IadminORACLE_SIDcreatecreatedb
set echo on
connect INTERNAL/oracle
startup nomount pfile=C:ORACLE8IadminORACLE_SIDpfileinit.ora
CREATE DATABASE ORACLE_SID
LOGFILE 'C:ORACLE8IoradataORACLE_SIDredo01.log' SIZE 1024K,
'C:ORACLE8IoradataORACLE_SIDredo02.log' SIZE 1024K
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXLOGHISTORY 1
DATAFILE 'C:ORACLE8IoradataORACLE_SIDsystem01.dbf' SIZE 50M REUSE
MAXDATAFILES 254
MAXINSTANCES 1
CHARACTER SET ZHT16BIG5
NATIONAL CHARACTER SET ZHT16BIG5;
spool off
--ORACLE_SIDrun1.sql
spool C:ORACLE8IadminORACLE_SIDcreatecreatedb1
set echo on
connect INTERNAL/oracle
ALTER DATABASE DATAFILE 'C:ORACLE8IoradataORACLE_SIDsystem01.dbf' AUTOEXTEND ON;
CREATE ROLLBACK SEGMENT SYSROL TABLESPACE "SYSTEM" STORAGE (INITIAL 100K NEXT 100K);
ALTER ROLLBACK SEGMENT "SYSROL" ONLINE;
另外我要说的是,新建全局数据库后:
sys的口令是:change_on_install
system的口令是:manager
第一次启动的服务器有:
OracleOraHome90Agent
OracleOraHome90TNSListen
OracleService(你数据库名字:例如你建立的数据库和SID名为:NEW,那这里就是NEW)