① Oracle新建数据

Oracle新建数据库可以参考以下操作方法:

1、首先点击桌面左下角的开始图标;

② Oracle 9i如何用SQL语句创建数据库

手工创建数据库完整步骤
系统环境
操作系统:RedHat 9.2
数据库:Oracle 9i
安装路径:/home/oracle
1、手工创建相关目录
/home/oracle/admin/web
/home/oracle/admin/web/bmp
/home/oracle/admin/web/ump
/home/oracle/admin/web/cmp
/home/oracle/admin/web/pfile
/home/oracle/admin/web/create
/home/oracle/admin/web/web
/home/oracle/admin/web/archive
/home/oracle/oradata/home/oracle/oradata/web
/home/oracle/oradata/web/archive
2、手工创建初始化参数文件/home/oracle/admin/web/pfile/initweb.ora,内容可以别的实例initsid.ora文件后修改。
3、手工创建/home/oracle/OraHome1/dbs/initweb.ora文件,
内容:ifile= /home/oracle/admin/web/pfile/initweb.ora
4、使用orapwd命令,创建口令文件orapwdsid,命令格式如下:
orapwd file=/home/oracle/OraHome1/dbs/orapwweb password=change_on_install entries=5
5、设置环境变量
export PATH LD_ASSUME_KERNEL=2.4.1
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=/home/oracle/OraHome1
export ORACLE_SID=web
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=$PATH: $ORACLE_HOME/bin
6、创建数据库,执行createdb.sql脚本命令,
$ sqlplus /nolog
SQL>connect sys/change_on_install as sysdba
SQL>@Createdb.sql
Createdb.sql脚本内容如下:
set echo on
spool /home/oracle/admin/web/create/CreateDB.log
startup nomount pfile="/home/oracle/admin/web/pfile/initweb.ora";
CREATE DATABASE web
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
DATAFILE '/home/oracle/oradata/web/system01.dbf' SIZE 325M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
UNDO TABLESPACE "UNDOSTB1" DATAFILE '/home/oracle/oradata/web/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/home/oracle/oradata/web/redo01.log') SIZE 100M,
GROUP 2 ('/home/oracle/oradata/web/redo02.log') SIZE 100M,
GROUP 3 ('/home/oracle/oradata/web/redo03.log') SIZE 100M;
spool off
注:创建数据库时,执行sql.bsqj脚本命令,此脚本命令创建如下内容:
创建控制文件和联机日志文件
创建数据库系统表空system
在system表空间上创建system系统回滚段
创建sys和system账号
创建基表和簇
创建数据字典表、索引和序列
创建相关角色权限
7、创建数据库数据文件,执行脚本createfiles.sql
$sqlplus /nolog
SQL> connect sys/change_on_install as sysdba
SQL>@createfiles.sql
Createfiles.sql脚本内容如下:
set echo on
spool /home/oracle/admin/web/create/CreateDBFiles.log
CREATE TABLESPACE "INDX" LOGGING DATAFILE '/home/oracle/oradata/web/indx01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
CREATE TEMPORARY TABLESPACE "TEMP" TEMPFILE '/home/oracle/oradata/web/temp01.dbf' SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE "TEMP";
CREATE TABLESPACE "TOOLS" LOGGING DATAFILE '/home/oracle/oradata/web/tools01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
CREATE TABLESPACE "USERS" LOGGING DATAFILE '/home/oracle/oradata/web/users01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
CREATE UNDO TABLESPACE "UNDOSTB1" DATAFILE '/home/oracle/oradata/web/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K;
spool off
exit;
~8、创建数据字典,运行createdbcatalog.sql脚本命令
$sqlplus /nolog
SQL> connect sys/change_on_install as sysdba
SQL>@createdbcatalog.sql
Createdbcatalog.sql脚本内容如下:

set echo on
spool /home/oracle/admin/web/create/CreateDBCatalog.log
@/home/oracle/OraHome1/rdbms/admin/catalog.sql;
@/home/oracle/OraHome1/rdbms/admin/catexp7.sql;
@/home/oracle/OraHome1/rdbms/admin/catblock.sql;
@/home/oracle/OraHome1/rdbms/admin/catproc.sql;
@/home/oracle/OraHome1/rdbms/admin/catoctk.sql;
@/home/oracle/OraHome1/rdbms/admin/catobtk.sql;
@/home/oracle/OraHome1/rdbms/admin/caths.sql;
@/home/oracle/OraHome1/rdbms/admin/owminst.plb;
connect SYSTEM/manager
@/home/oracle/OraHome1/sqlplus/admin/pupbld.sql;
connect SYSTEM/manager
set echo on
spool /home/oracle/OraHome1/assistants/dbca/logs/sqlPlusHelp.log
@/home/oracle/OraHome1/sqlplus/admin/help/hlpbld.sql helpus.sql;
spool off
spool off
exit;9、完善数据库,创建spfile文件,将数据库实例启动服务设置成自动启动方式。
SQL>sqlplus /nolog
SQL> connect sys/change_on_install as sysdba
SQL> @postdbcreation.sql
Postdbcreation.sql脚本内容如下:
set echo on
spool /home/oracle/admin/web/create/postDBCreation.log
create spfile='/home/oracle/OraHome1/database/spfileweb.ora' FROM pfile='/home/oracle/admin/web/pfile/initweb.ora';
connect SYS/change_on_install as SYSDBA
set echo on
spool /home/oracle/OraHome1/assistants/dbca/logs/postDBCreation.log
shutdown;
startup;