Creating a Database with the CREATE DATABASE Statement(手工建库)

Complete the following steps to create a database with the CREATE DATABASE statement. The examples create a database named mynewdb.
Step 1: Specify an Instance Identifier (SID)  --- 指定ORACLE_SID
The following example for UNIX and Linux operating systems sets the SID for the instance that you will connect to in Step 6: Connect to the Instance:
  • Bourne, Bash, or Korn shell:
    ORACLE_SID=mynewdb export ORACLE_SID

  • C shell:
    setenv ORACLE_SID mynewdb

  • The following example sets the SID for the Windows operating system:
    set ORACLE_SID=mynewdb

Step 2: Ensure That the Required Environment Variables Are Set   --- 确保所需环境变量
           

Depending on your platform, before you can start SQL*Plus (as required in Step 6: Connect to the Instance), you may have to set environment variables, or at least verify that they are set properly.

For example, on most platforms, ORACLE_SID and ORACLE_HOME must be set. In addition, it is advisable to set the PATH variable to include the ORACLE_HOME/bin directory. On the UNIX and Linux platforms, you must set these environment variables manually. On the Windows platform, OUI automatically assigns values to ORACLE_HOME and ORACLE_SID in the Windows registry. If you did not create a database upon installation, OUI does not set ORACLE_SID in the registry, and you will have to set the ORACLE_SID environment variable when you create your database later

---之前根据你的平台,你可以开始SQL * Plus(根据需要在步骤6:连接到实例),您可能需要设置环境变量,或者至少确认他们是正确设置。
例如,在大多数平台上,ORACLE_SID ORACLE_HOME必须设置,另外,建议设置PATH变量包括ORACLE_HOME / bin目录中。在UNIX和Linux平台上,您必须手动设置这些环境变量。在Windows平台上,是的自动分配值ORACLE_HOME和ORACLE_SID Windows注册表。如果你没有创建一个数据库安装,是的不设置ORACLE_SID在注册表中,你必须设置ORACLE_SID环境变量以后当您创建您的数据库

Step 3: Choose a Database Administrator Authentication Method  --- 选择一个数据库管理员身份验证方法  (也就是创建密码文件) 

命令:ORAPWD FILE= filename [ENTRIES= numusers] [FORCE={Y|N}] [IGNORECASE={Y|N}]
 ---  orapwd file=XXX  password=XXX   也可以设置密码
下图解释:上一句的含义
bb
不同平台之间密码文件所放的地址和密码文件格式!
bb
Step 4: Create the Initialization Parameter File --- 创建初始化参数文件

Recommended Minimum Initialization Parameters   ---推荐最小参数  (也就是说最少得有这几个)

DB_NAME

Yes

Database identifier. Must correspond to the value used in the CREATE DATABASE statement. Maximum 8 characters.

CONTROL_FILES

No

Strongly recommended. If not provided, then the database instance creates one control file in the same location as the initialization parameter file. Providing this parameter enables you to multiplex control files. See "Creating Initial Control Files" for more information.

MEMORY_TARGET

No

Sets the total amount of memory used by the instance and enables automatic memory management. You can choose other initialization parameters instead of this one for more manual control of memory usage. See "Configuring Memory Manually".



例如 在Linux 下设置
/u01/app/oracle/product/11.2.0/dbs

[oracle@oggdb2 oradata]$ mkdir mydb
[oracle@oggdb2 oradata]$ cd mydb
[oracle@oggdb2 mydb]$ pwd
/u01/app/oracle/oradata/mydb
vi initmynewdb.ora
db_name=mynewdb
CONTROL_FILES='/u01/app/oracle/oradata/mydb/control01.ctl','/u01/app/oracle/oradata/mydb/control02.ctl'
MEMORY_TARGET=1024M

Step 5: (Windows Only) Create an Instance

Enter the following command at a Windows command prompt:

oradim -NEW -SID sid -STARTMODE MANUAL -PFILE pfile 

where sid is the desired SID (for example mynewdb) and pfile is the full path to the text initialization parameter file. This command creates the instance but does not start it.

Step 6: Connect to the Instance   --连接到数据库实例

To authenticate with a password file, enter the following commands, and then enter the SYS password when prompted:
--验证密码文件,输入以下命令,然后在提示的时候输入系统密码:

$ sqlplus /nolog SQL> CONNECT SYS AS SYSDBA

 

To authenticate with operating system authentication, enter the following commands:
与操作系统身份验证,验证输入以下命令

$ sqlplus /nolog
SQL> CONNECT / AS SYSDBA

SQL*Plus outputs the following message:

Connected to an idle instance.


Step 7: Create a Server Parameter File   ------   创建一个服务器参数文件

可以先验证下pfile  
SQL> startup nomount pfile='/u01/app/oracle/product/11.2.0/dbs/initmynewdb.ora'
然后创建 spfile
CREATE SPFILE FROM PFILE;
你可以指定路径和名称,不指定使用默认的。

Step 8: Start the Instance

STARTUP NOMOUNT

---注意先关了再启动    可以用命令
show parameter spfile/pfile

Step 9: Issue the CREATE DATABASE Statement   --- 创建数据库语句


CREATE DATABASE mynewdb
   USER SYS IDENTIFIED BY sys_password
   USER SYSTEM IDENTIFIED BY system_password
   LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log') SIZE 100M BLOCKSIZE 512,
           GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log') SIZE 100M BLOCKSIZE 512,
           GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log') SIZE 100M BLOCKSIZE 512
   MAXLOGFILES 5
   MAXLOGMEMBERS 5
   MAXLOGHISTORY 1
   MAXDATAFILES 100
   CHARACTER SET US7ASCII
   NATIONAL CHARACTER SET AL16UTF16
   EXTENT MANAGEMENT LOCAL
   DATAFILE '/u01/app/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE
   SYSAUX DATAFILE '/u01/app/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE
   DEFAULT TABLESPACE users
      DATAFILE '/u01/app/oracle/oradata/mynewdb/users01.dbf'
      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
   DEFAULT TEMPORARY TABLESPACE tempts1
      TEMPFILE '/u01/app/oracle/oradata/mynewdb/temp01.dbf'
      SIZE 20M REUSE
   UNDO TABLESPACE undotbs
      DATAFILE '/u01/app/oracle/oradata/mynewdb/undotbs01.dbf'
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;


Step 10: Create Additional Tablespaces  -- 创建额外表空间

CREATE TABLESPACE apps_tbs LOGGING
     DATAFILE '/u01/app/oracle/oradata/mynewdb/apps01.dbf'
     SIZE 500M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
     EXTENT MANAGEMENT LOCAL;
-- create a tablespace for indexes, separate from user tablespace (optional)
CREATE TABLESPACE indx_tbs LOGGING
     DATAFILE '/u01/app/oracle/oradata/mynewdb/indx01.dbf'
     SIZE 100M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
     EXTENT MANAGEMENT LOCAL;

Step 11: Run Scripts to Build Data Dictionary Views  --- 运行脚本构建数据字典视图

Run the scripts necessary to build data dictionary views, synonyms, and PL/SQL packages, and to support proper functioning of SQL*Plus:
运行所需的脚本构建数据字典视图、同义词、和PL / SQL的软件包,并支持SQL * Plus的正常运行:

 

@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/sqlplus/admin/pupbld.sql
EXIT


 

The at-sign (@) is shorthand for the command that runs a SQL*Plus script. The question mark (?) is a SQL*Plus variable indicating the Oracle home directory. The following table contains descriptions of the scripts:

Script Description
CATALOG.SQL Creates the views of the data dictionary tables, the dynamic performance views, and public synonyms for many of the views. Grants PUBLIC access to the synonyms.
CATPROC.SQL Runs all scripts required for or used with PL/SQL.
PUPBLD.SQL Required for SQL*Plus. Enables SQL*Plus to disable commands by user.

Step 12: (Optional) Run Scripts to Install Additional Options  -- 可以自己选择运行脚本安装额外的选项 根据需求指定自己要的脚本

Step 13: Back Up the Database.    ----  备份数据库

Step 14: (Optional) Enable Automatic Instance Startup  ---  可以自己设定启用自动启动实例


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30173898/viewspace-1471219/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30173898/viewspace-1471219/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值