第一部分(window)
一删除数据库的方法:
1) DBCA,这样删除的比较干净
2)用命令删除
比如数据的实例名称nbo
oradim -delete -sid nbo
删除相应的文件 参数文件,控制文件,数据文件等
二创建数据库的方法
1)设置环境变量
set ORACLE_SID=oratest
2创建实例
ORADIM -NEW -SID oratest -SYSPWD 123456 -PFILE D:\oracle\product\10.1.0\admin\oratest\pfile\init.ora
init.ora可以从系统里面其他数据库拷贝,修改里面的默认名称为oratest即可。oratest下面包含
文件夹,pfile下面要有init.ora文件
3创建文件
sql>sqlplus /nolog
sql>create spfile='D:\oracle\product\10.1.0\Db_1\database\spfileoratest.ora' from pfile='D:\oracle\product\10.1.0\admin\oratest\pfile\init.ora';
4创建数据库
建立存放控制文件的目录,否则创建控制文件会报错
SQL> startup nomount;
sql>CREATE DATABASE oratest
LOGFILE GROUP 1 ('d:\oracle\product\10.1.0\oradata\oratest\redo01.log') SIZE 50M,
GROUP 2 ('d:\oracle\product\10.1.0\oradata\oratest\redo02.log') SIZE 50M,
GROUP 3 ('d:\oracle\product\10.1.0\oradata\oratest\redo03.log') SIZE 50M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
DATAFILE 'd:\oracle\product\10.1.0\oradata\oratest\system01.dbf' SIZE 325M AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE 'd:\oracle\product\10.1.0\oradata\oratest\sysaux01.dbf' SIZE 325M
UNDO TABLESPACE UNDOTBS1 DATAFILE 'd:\oracle\product\10.1.0\oradata\oratest\UNDOTBS1.dbf' size 50M
AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED;
5创建临时表空间
CREATE TEMPORARY TABLESPACE TEMP TEMPFILE 'd:\ORACLE\PRODUCT\10.1.0\ORADATA\ORATEST\TEMP01.DBF' SIZE 1000M EXTENT MANAGEMENT LOCAL;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP;
6创建用户表空间
create tablespace USERS datafile 'd:\ORACLE\PRODUCT\10.1.0\ORADATA\ORATEST\USERS01.DBF' SIZE 100M EXTENT MANAGEMENT LOCAL;
7创建默认表空间
create tablespace TBS datafile 'd:\ORACLE\PRODUCT\10.1.0\ORADATA\ORATEST\TBS01.DBF' SIZE 1000M EXTENT MANAGEMENT LOCAL;
ALTER DATABASE DEFAULT TABLESPACE TBS;
8加载数据字典
@d:\oracle\product\10.1.0\db_1\rdbms\admin\catalog.sql --用来创建数据库的数据字典文件的,
@d:\oracle\product\10.1.0\db_1\rdbms\admin\catproc.sql --用来创建数据库的基本过程和包的。
@d:\oracle\product\10.1.0\db_1\rdbms\admin\catexp7.sql --EXP/IMP导入导出
@d:\oracle\product\10.1.0\db_1\sqlplus\admin\caths.sql
@d:\oracle\product\10.1.0\db_1\sqlplus\admin\help\hlpbld.sql helpus.sql
第二部分(linux)
linux操作系统下面创建数据库
一创建密码文件
orapwd FILE=orapwrm ENTRIES=30 password=123456
二创建参数文件
initrm.ora
包含以下参数
undo_management=AUTO
undo_tablespace=undotbs
db_name=rm
pga_aggregate_target=25165824
control_files=(/opt/ora10/oradata/rm/ora_control1, /opt/ora10/oradata/rm/ora_control2)
三创建spfile同时启动实例
create spfile from pfile
startup nomount
四创建数据库
CREATE DATABASE rm
USER SYS IDENTIFIED BY password
USER SYSTEM IDENTIFIED BY password
LOGFILE GROUP 1 ('/opt/ora10/oradata/rm/redo01a.log','/opt/ora10/oradata/rm/redo01b.log') SIZE 100M ,
GROUP 2 ('/opt/ora10/oradata/rm/redo02a.log','/opt/ora10/oradata/rm/redo02b.log') SIZE 100M ,
GROUP 3 ('/opt/ora10/oradata/rm/redo03a.log','/opt/ora10/oradata/rm/redo03b.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/opt/ora10/oradata/rm/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/opt/ora10/oradata/rm/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users DATAFILE '/opt/ora10/oradata/rm/users01.dbf' SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1 TEMPFILE '/opt/ora10/oradata/rm/temp01.dbf' SIZE 20M REUSE
UNDO TABLESPACE undotbs DATAFILE '/opt/ora10/oradata/rm/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
五执行必须脚本
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/sqlplus/admin/pupbld.sql