1.   Creating a Database with DBCA

DatabaseConfiguration Assistant (DBCA) is the preferred way to create a database,because it is a more automated approach, and your database is ready to use whenDBCA completes. DBCA can be launched by the Oracle Universal Installer (OUI),depending upon the type of install that you select. You can also launch DBCA asa standalone tool at any time after Oracle Database installation. You can runDBCA in interactive mode or noninteractive/silent mode. Interactivemodeprovides a graphical interface and guided workflow for creating and configuringa database. Noninteractive/silent mode enables you to script database creation.You can run DBCA in noninteractive/silent mode by specifying command-linearguments, a response file, or both.

1.1 Creating a Database with Interactive DBCA

1.2  Creating a Database with Noninteractive/Silent DBCA

The following examplecreates a database by passing command-line arguments to DBCA:

dbca -silent -createDatabase-templateName General_Purpose.dbc

-gdbname ora11g -sidora11g -responseFile NO_VALUE -characterSet AL32UTF8

-memoryPercentage 30-emConfiguration LOCAL

Enter SYSTEM userpassword:

password

Enter SYS userpassword:

password

Copying database files

1% complete

3% complete

...

To ensure completely silent operation, you can redirect stdout to a file.In this case, however, you must supply passwords for the administrativeaccounts in command-line arguments or the response file.

To view brief help for DBCA command-line arguments, enter the followingcommand:

dbca -help

For more detailed argument information, including defaults, view theresponse file template found on your distribution media. Appendix A of yourplatform installation guide provides the name and location of this file.

dbca -help

dbca  [-silent | -progressOnly |-customCreate] {<command> <options> }  | { [<command> [options] ]-responseFile  <response file > }[-continueOnNonFatalErrors <true | false>]

有关详细信息, 请参阅手册。

可以输入以下命令之一:

通过指定以下参数创建数据库:

-createDatabase

-templateName <默认位置或完整模板路径中现有模板的名称>

[-cloneTemplate]

-gdbName <全局数据库名>

[-sid <数据库系统标识符>]

[-sysPassword <SYS 用户口令>]

[-systemPassword <SYSTEM 用户口令>]

[-emConfiguration <CENTRAL|LOCAL|ALL|NONE>

-dbsnmpPassword <DBSNMP 用户口令>

-sysmanPassword <SYSMAN 用户口令>

[-hostUserName <EM 备份作业的主机用户名>

-hostUserPassword <EM 备份作业的主机用户口令>

-backupSchedule <使用 hh:mm 格式的每日备份计划>]

[-centralAgent <Enterprise Manager 中央代理主目录>]]

[-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE>

[-datafileDestination <所有数据库文件的目标目录> |  -datafileNames <含有诸如控制文件, 表空间, 重做日志文件数据库对象以及按 name=value 格式与这些对象相对应的裸设备文件名映射的 spfile 的文本文件。>]

[-redoLogFileSize <每个重做日志文件的大小 (MB)>]

[-recoveryAreaDestination <所有恢复文件的目标目录>]

[-datafileJarLocation  <数据文件 jar 的位置, 只用于克隆数据库的创建>]

[-storageType < FS | ASM >

[-asmsnmpPassword     <用于 ASM 监视的 ASMSNMP 口令>]

-diskGroupName   <数据库区磁盘组名>

-recoveryGroupName       <恢复区磁盘组名>

[-characterSet <数据库的字符集>]

[-nationalCharacterSet  <数据库的国家字符集>]

[-registerWithDirService <true | false>

-dirServiceUserName    <目录服务的用户名>

-dirServicePassword    <目录服务的口令>

-walletPassword    <数据库 Wallet 的口令>]

[-listeners  <监听程序列表, 该列表用于配置具有如下对象的数据库>]

[-variablesFile   <用于模板中成对变量和值的文件名>]]

[-variables  <以逗号分隔的name=value 对列表>]

[-initParams <以逗号分隔的 name=value 对列表>]

[-sampleSchema  <true |false> ]

[-memoryPercentage <用于 Oracle 的物理内存百分比>]

[-automaticMemoryManagement ]

[-totalMemory <为 Oracle 分配的内存(MB)>]

[-databaseType <MULTIPURPOSE|DATA_WAREHOUSING|OLTP>]]

通过指定以下参数来配置数据库:

-configureDatabase

-sourceDB    <源数据库 sid>

[-sysDBAUserName     <用户名 (具有 SYSDBA 权限)>

-sysDBAPassword     <sysDBAUserName 用户名的口令>]

[-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword<true | false>

-dirServiceUserName    <目录服务的用户名>

-dirServicePassword    <目录服务的口令>

-walletPassword    <数据库 Wallet 的口令>]

[-disableSecurityConfiguration<ALL|AUDIT|PASSWORD_PROFILE|NONE>

[-enableSecurityConfiguration<true|false>

[-emConfiguration<CENTRAL|LOCAL|ALL|NONE>

-dbsnmpPassword <DBSNMP 用户口令>

-sysmanPassword <SYSMAN 用户口令>

[-hostUserName <EM 备份作业的主机用户名>

-hostUserPassword <EM 备份作业的主机用户口令>

-backupSchedule <使用 hh:mm 格式的每日备份计划>]

[-centralAgent <EnterpriseManager 中央代理主目录>]]

通过指定以下参数使用现有数据库创建模板

-createTemplateFromDB

-sourceDB    <服务采用<host>:<port>:<sid> 格式>

-templateName      <新的模板名>

-sysDBAUserName     <用户名 (具有 SYSDBA 权限)>

-sysDBAPassword     <sysDBAUserName 用户名的口令>

[-maintainFileLocations<true | false>]

通过指定以下参数使用现有数据库创建克隆模板:

-createCloneTemplate

-sourceSID    <源数据库 sid>

-templateName      <新的模板名>

[-sysDBAUserName     <用户名 (具有 SYSDBA 权限)>

-sysDBAPassword     <sysDBAUserName 用户名的口令>]

[-maintainFileLocations<true | false>]

[-datafileJarLocation       <存放压缩格式数据文件的目录>]

通过指定以下参数生成脚本以创建数据库:

-generateScripts

-templateName <默认位置或完整模板路径中现有模板的名称>

-gdbName <全局数据库名>

[-scriptDest       <所有脚本文件的目标位置>]

通过指定以下参数删除数据库:

-deleteDatabase

-sourceDB    <源数据库 sid>

[-sysDBAUserName     <用户名 (具有 SYSDBA 权限)>

-sysDBAPassword     <sysDBAUserName 用户名的口令>]

通过指定以下选项来查询帮助: -h | -help

2. Creating a Database with the CREATE DATABASE Statement

Using the CREATE DATABASE SQL statement is amore manual approach to creating a database. One advantage of using thisstatement over using DBCA is that you can create databases from within scripts.If you use the CREATE DATABASE statement, you mustcomplete additional actions before you have an operational database. Theseactions include building views on the data dictionary tables and installingstandard PL/SQL packages. You perform these actions by running the suppliedscripts.

If you have existing scripts for creating your database, consider editingthose scripts to take advantage of new Oracle Database features. Theinstructions in this section apply to single-instance installations only. See the Oracle RealApplication Clusters (Oracle RAC) installation guide for your platform for instructionsfor creating an Oracle RAC database.

Step 1: Specify an InstanceIdentifier (SID)

Thefollowing example for UNIX and Linux operating systems sets the SID for theinstancethat you will connect to in Step 6: Connect to the Instance:

1.Bourne, Bash, orKorn shell:

ORACLE_SID=mynewdb

export ORACLE_SID

2.C shell:

setenv ORACLE_SID mynewdb

The following examplesets the SID for the Windows operating system:

set ORACLE_SID=mynewdb

Step 2: Ensure That the RequiredEnvironment 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 setenvironment variables, or at least verify that they are set properly. Forexample, 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 variablesmanually. On the Windows platform, OUI automatically assigns values to ORACLE_HOME and ORACLE_SID in the Windows registry. Ifyou did not create a database upon installation, OUI does not set ORACLE_SID in the registry, and you willhave to set the ORACLE_SIDenvironmentvariable when you create your database later.

Step 3: Choose a DatabaseAdministrator Authentication Method

You must be authenticated and granted appropriate system privileges inorder to create a database. You can be authenticated as an administrator withthe required privileges in the following ways:

■ With a password file

■ With operating system authentication

In this step, you decide on an authentication method.

To be authenticated with a password file, create thepassword file as described in "Creating and Maintaining a PasswordFile" on page 1-22. To be authenticated with operating systemauthentication, ensure that you log in to the host computer with a user accountthat is a member of the appropriate operating system user group. On the UNIXand Linux platforms, for example, this is typically the dba user group. On the Windowsplatform, the user installing the Oracle software is automatically placed in therequired user group.

ORAPWD FILE=filename [ENTRIES=numusers][FORCE={Y|N}] [IGNORECASE={Y|N}]

Step 4: Create the InitializationParameter File

When an Oracle instance starts, it reads aninitialization parameter file. This file can be a text file, which can becreated and modified with a text editor, or a binary file, which is created anddynamically modified by the database. The binary file, which is preferred, iscalled a serverparameter file. In this step, you create a text initialization parameterfile. In a later step, you create a server parameter file from the text file.One way to create the text initialization parameter file is to edit the samplepresented in "Sample Initialization Parameter File" on page 2-26.  If you create the initialization parameterfile manually, ensure that it contains at least the parameters listed in Table2–2. All other parameters not listed have default values.

For convenience, store your initialization parameter file in the OracleDatabase default location, using the default file name. Then when you startyour database, it will not be necessary to specify the PFILE clause of the STARTUPcommand, becauseOracle Database automatically looks in the default location for theinitialization parameter file.

Csong.__db_cache_size=1845493760

Csong.__java_pool_size=16777216

Csong.__large_pool_size=33554432

Csong.__oracle_base='D:\app\Csong'#ORACLE_BASEset from environment

Csong.__pga_aggregate_target=822083584

Csong.__sga_target=2449473536

Csong.__shared_io_pool_size=0

Csong.__shared_pool_size=503316480

Csong.__streams_pool_size=16777216

*.audit_file_dest='D:\app\Csong\admin\Csong\adump'

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.control_files='D:\app\Csong\oradata\Csong\control01.ctl','D:\app\Csong\fast_recovery_area\Csong\control02.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='Csong'

*.db_recovery_file_dest='D:\app\Csong\fast_recovery_area'

*.db_recovery_file_dest_size=4385144832

*.diagnostic_dest='D:\app\Csong'

*.dispatchers='(PROTOCOL=TCP)(SERVICE=CsongXDB)'

*.local_listener='LISTENER_Csong'

*.nls_language='SIMPLIFIEDCHINESE'

*.nls_territory='CHINA'

*.open_cursors=300

*.pga_aggregate_target=812646400

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=2438987776

*.undo_tablespace='UNDOTBS1'

Step 5: (Windows Only) Create anInstance

On the Windows platform, before you can connect to an instance, you mustmanually create it if it does not already exist. The ORADIM command creates an Oracle instance by creating a newWindows service.

To 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 textinitialization parameter file. This command creates the instance but does notstart it.

Caution: Do not set the -STARTMODEargument to AUTO at this point, because this causes the new instance tostart and attempt to mount the database, which does not exist yet. You canchange this parameter to AUTO, if desired, in Step14.

Start SQL*Plus and connect to your Oracle Database instance with the SYSDBA system

privilege.

■ To authenticate with a password file, enter the followingcommands, and then

enter the SYS password whenprompted:

$ sqlplus /nolog

SQL> CONNECT SYSAS SYSDBA

■ To authenticate with operating system authentication,enter the following

commands:

$ sqlplus /nolog

SQL> CONNECT / ASSYSDBA

SQL*Plus outputs the following message:

Connected to an idleinstance.

Note: SQL*Plus may output a message similar to the following:

Connected to:

Oracle Database 11gEnterprise Edition Release 11.2.0.1.0 - Production

With thePartitioning, OLAP and Data Mining options

If so, the instance is already started. You may have connected to thewrong instance. Exit SQL*Plus with the EXIT command, check that ORACLE_SID is set properly, and repeat this step.

Step 7: Create a Server ParameterFile

The server parameter file enables you to change initialization parameterswith the ALTER SYSTEM command and persistthe changes across a database shutdown and startup. You create the serverparameter file from your edited text initialization file.

The following SQL*Plus command reads the text initialization parameterfile (PFILE) with the default name from the default location, creates a serverparameter file (SPFILE) from the text initialization parameter file, and writesthe SPFILE to the default location with the default SPFILE name.

CREATE SPFILE FROMPFILE;

You can also supply the file name and path for both the PFILE and SPFILEif you are not using default names and locations.

Tip: The database must be restarted before the serverparameter file takes effect.

Note: Although creating a serverparameter file is optional at this point, it is recommended. If you do notcreate a server parameter file, the instance continues to read the textinitialization parameter file

whenever it starts.

Important—If you are using OracleManaged Files and your initialization parameter file does not contain the CONTROL_FILES parameter,then you must create a server parameter file now so the database can save thenames and location of the control files that it creates during the CREATE DATABASE statement. See "SpecifyingOracle Managed Files at Database Creation" on page 2-19 for more information.

Step 8: Start the Instance

Start an instance without mounting a database. Typically, you do this onlyduring database creation or while performing maintenance on the database. Usethe STARTUP command with the NOMOUNT clause. In this example, because the initialization parameterfile or server parameter file is stored in the default location, you are not requiredto specify the PFILE clause:

STARTUP NOMOUNT

At this point, the instance memory is allocated and its processes arestarted. The database itself does not yet exist.

Step 9: Issue the CREATE DATABASEStatement

To create the newdatabase, use the CREATE DATABASE statement.

Example 1

The following statement creates database mynewdb. This database name must agree with the DB_NAME parameter in the initialization parameter file. Thisexample assumes the following:

■ The initialization parameter file specifies the numberand location of control files with the CONTROL_FILES parameter.

■ The directory /u01/app/oracle/oradata/mynewdbexists.

■ The directories /u01/logs/myand /u02/logs/my exist.

CREATE DATABASE Csong

USER SYS IDENTIFIEDBY sys

USER SYSTEMIDENTIFIED BY sys

LOGFILE GROUP 1('D:\app\Csong\oradata\Csong\redo01a.log') SIZE 100M BLOCKSIZE 512,

GROUP 2('D:\app\Csong\oradata\Csong\redo02a.log') SIZE 100M BLOCKSIZE 512,

GROUP 3('D:\app\Csong\oradata\Csong\redo03a.log') SIZE 100M BLOCKSIZE 512

MAXLOGFILES 32

MAXLOGMEMBERS 5

MAXLOGHISTORY 1

MAXDATAFILES 100

CHARACTER SETAL32UTF8

NATIONAL CHARACTERSET AL16UTF16

EXTENT MANAGEMENTLOCAL

DATAFILE'D:\app\Csong\oradata\Csong\system01.dbf' SIZE 325M REUSE

SYSAUX DATAFILE'D:\app\Csong\oradata\Csong\sysaux01.dbf' SIZE 325M REUSE

DEFAULT TABLESPACEusers

DATAFILE'D:\app\Csong\oradata\Csong\users01.dbf'

SIZE 500M REUSEAUTOEXTEND ON MAXSIZE UNLIMITED

DEFAULT TEMPORARYTABLESPACE tempts1

TEMPFILE'D:\app\Csong\oradata\Csong\temp01.dbf'

SIZE 20M REUSE

UNDO TABLESPACEundotbs1

DATAFILE'D:\app\Csong\oradata\Csong\undotbs01.dbf'

SIZE 200M REUSEAUTOEXTEND ON MAXSIZE UNLIMITED;

Example 2

This example illustrates creating a database with Oracle Managed Files,which enables you to use a much simpler CREATE DATABASE statement. To use Oracle Managed Files, theinitialization parameter DB_CREATE_FILE_DESTmust be set. Thisparameter defines the base directory for the various database files that thedatabase creates and automatically names. The following statement is an exampleof setting this parameter in the initialization parameter file:

DB_CREATE_FILE_DEST='/u01/app/oracle/oradata'

With Oracle Managed Files and the following CREATE DATABASE statement, the database creates the SYSTEM and SYSAUX tablespaces, createsthe additional tablespaces specified in the statement, and chooses defaultsizes and properties for all data files, control files, and redo log files.Note that these properties and the other default database properties set bythis method may not be suitable for your production environment, so it isrecommended that you examine the resulting configuration and

modify it if necessary.

CREATE DATABASEmynewdb

USER SYS IDENTIFIEDBY sys_password

USER SYSTEM IDENTIFIEDBY system_password

EXTENT MANAGEMENTLOCAL

DEFAULT TEMPORARYTABLESPACE temp

UNDO TABLESPACEundotbs1

DEFAULT TABLESPACEusers;

Tip: If your CREATE DATABASE statementfails, and if you did not complete Step 7, then ensure that there is not a pre-existingserver parameter file (SPFILE) for this instance that is setting initialization

parameters in an unexpected way. For example, an SPFILEcontains a setting for the complete path to all control files, and the CREATE DATABASE statement fails if thosecontrol files do not exist. Ensure that you shut down and restart the instance(with STARTUP NOMOUNT) after removingan unwanted SPFILE. See "Managing Initialization Parameters Using a ServerParameter File" on page 2-32 for more information.

Step 10: Create AdditionalTablespaces

To make the database functional, you must create additional tablespacesfor your application data. The following sample script creates some additionaltablespaces:

CREATE TABLESPACEapps_tbs LOGGING

DATAFILE '/u01/app/oracle/oradata/mynewdb/apps01.dbf'

SIZE 500M REUSEAUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED

EXTENT MANAGEMENTLOCAL;

-- create atablespace for indexes, separate from user tablespace (optional)

CREATE TABLESPACEindx_tbs LOGGING

DATAFILE'/u01/app/oracle/oradata/mynewdb/indx01.dbf'

SIZE 100M REUSEAUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED

EXTENT MANAGEMENTLOCAL;

Step 11: Run Scripts to Build DataDictionary Views

Run the scripts necessary to build data dictionary views, synonyms, andPL/SQL

packages, and to support proper functioning of SQL*Plus.

In SQL*Plus, connect to your Oracle Database instance with the SYSDBA administrative

privilege:

@?/rdbms/admin/catalog.sql

@?/rdbms/admin/catproc.sql

In SQL*Plus, connect to your Oracle Database instance as SYSTEM user:

@?/sqlplus/admin/pupbld.sql

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

Step 12: (Optional) Run Scripts toInstall Additional Options

Step 13: Back Up the Database.

Step 14: (Optional) EnableAutomatic Instance Startup

 

That's all!

 

Windows下Oracle创建数据库的3种方式的更多相关文章

  1. SQLite3学习笔记----创建数据库的两种方式

    今天研究学习SQLite,刚开始创建数据库,就遇到了一个坑,是自己粗心了,特记录一下. 实验环境: OS:Ubuntu18.04 创建数据库名称:test.db 实验步骤: 1.检查是否已经安装了SQ ...

  2. windows下hash抓取的几种方式

    前提:在渗透测试过程中,对于windows系统的机器渗透需要注意hash的获取,其中hash分为LM-HASH与NTLM-HASH,在windows系统中,hash的默认存储位置为: C:\Windo ...

  3. windows下oracle数据库报错ORA-12705解决方法

    转自:http://blog.sina.com.cn/s/blog_16eaf6b940102x66q.html 有个朋友,他们那边windows虚拟机重启后,数据库不能起来报错ORA-12705无法 ...

  4. Windows下Oracle 11g的安装

    Windows下Oracle 11g的安装 Windows下Oracle 11g的安装: Windows:64位, Oracle 11g版本:win64_11gR2_database_1of2(安装包 ...

  5. Windows下Oracle 11g的下载与安装

    Windows下Oracle的下载与安装 一.Oracle下载 官网地址:http://www.oracle.com/technetwork/database/enterprise-edition/d ...

  6. [INS-30131] 执行安装程序验证所需的初始设置失败问题解决,windows下oracle安装步骤

    [INS-30131] 执行安装程序验证所需的初始设置失败问题解决,windows下oracle安装步骤 配置: 系统:windows10 数据库:Oracle Database 12c 第 1 版 ...

  7. plsql 连接oracle数据库的2种方式

      plsql 连接oracle数据库的2种方式 CreationTime--2018年8月10日09点50分 Author:Marydon 方式一:配置tnsnames.ora 该文件在instan ...

  8. Oracle 创建数据库卡死在85%

    Oracle 创建数据库卡死在85%处理方法 1.首先用改工具,删除数据库 2.对应的目录 3.重启服务器(本次尝试有重启,在有其他数据库在跑的情况下,可以试试不重启)

  9. windows下获取IP地址的两种方法

    windows下获取IP地址的两种方法: 一种可以获取IPv4和IPv6,但是需要WSAStartup: 一种只能取到IPv4,但是不需要WSAStartup: 如下: 方法一:(可以获取IPv4和I ...

随机推荐

  1. webstorm实用快捷键

    webstorm实用快捷键 Ctrl+/ 或 Ctrl+Shift+/ 注释(// 或者/*…*/ ) Shift+F6 重构-重命名 Ctrl+X 删除行 Ctrl+D 复制行 Ctrl+G 查找行 ...

  2. 怎样从外网访问内网Lighttpd?

    本地安装了一个Lighttpd,只能在局域网内访问,怎样从外网也能访问到本地的Lighttpd呢?本文将介绍具体的实现步骤. 准备工作 安装并启动Lighttpd 默认安装的Lighttpd端口是80 ...

  3. Linux环境nginx的配置

    1.创建nginx运行账户www并加入到www组,不允许www用户直接登录系统,查看创建. groupadd www useradd -g www www -s /bin/false tail /et ...

  4. js的匿名函数 和普通函数

    匿名函数在声明时不用带上函数名, 可以把匿名函数当作一个function类型的值来对待 声明一个普通的函数 function func() { ... } 可以认为和var func = functi ...

  5. shell 调试脚本设置

    set -x 脚本部分内容 set +x

  6. ODAC(V9.5.15) 学习笔记(四)TMemDataSet (1)

    所有的数据集类组件都是从TMemDataSet继承下来的,该组件实现了内存中对数据的管理,其主要的属性.方法和事件如下. 1.数据更新 名称 类型 说明 CachedUpdates Boolean 数 ...

  7. SpringBoot 全局统一记录日志

    1.记录日志 使用aop来记录controller中的请求返回日志 pom.xml引入: <dependency> <groupId>org.springframework.b ...

  8. 转方阵|2012年蓝桥杯B组题解析第五题-fishers

    (6')转方阵 对一个方阵转置,就是把原来的行号变列号,原来的列号变行号 例如,如下的方阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 转置后变为: 1 5 9 1 ...

  9. python 之 条件语句

    python 编程语言指定任何非0和非空(null)值为true, 0或者null为false. python 编程中if语句用于控制程序的执行,基本形式为: if 判断条件: 执行语句…… else ...

  10. volatile 变量使用

    1,对其它线程可见性.原理是:别的线程每次使用前都是要刷新一下值,并不是原子性同步.所有还是会出现线程不安全. 2,禁止指令重新排序.也就是会出现机器实际执行可能和代码的顺序不一样.使用volatil ...