Windows下Oracle创建数据库的3种方式
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.
l 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
l 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.
l 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}]
l 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'
l 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.
l 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.
l 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.
l 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.
l 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;
l 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:
l Step 12: (Optional) Run Scripts toInstall Additional Options
l Step 13: Back Up the Database.
l Step 14: (Optional) EnableAutomatic Instance Startup
That's all!
Windows下Oracle创建数据库的3种方式的更多相关文章
- SQLite3学习笔记----创建数据库的两种方式
今天研究学习SQLite,刚开始创建数据库,就遇到了一个坑,是自己粗心了,特记录一下. 实验环境: OS:Ubuntu18.04 创建数据库名称:test.db 实验步骤: 1.检查是否已经安装了SQ ...
- windows下hash抓取的几种方式
前提:在渗透测试过程中,对于windows系统的机器渗透需要注意hash的获取,其中hash分为LM-HASH与NTLM-HASH,在windows系统中,hash的默认存储位置为: C:\Windo ...
- windows下oracle数据库报错ORA-12705解决方法
转自:http://blog.sina.com.cn/s/blog_16eaf6b940102x66q.html 有个朋友,他们那边windows虚拟机重启后,数据库不能起来报错ORA-12705无法 ...
- Windows下Oracle 11g的安装
Windows下Oracle 11g的安装 Windows下Oracle 11g的安装: Windows:64位, Oracle 11g版本:win64_11gR2_database_1of2(安装包 ...
- Windows下Oracle 11g的下载与安装
Windows下Oracle的下载与安装 一.Oracle下载 官网地址:http://www.oracle.com/technetwork/database/enterprise-edition/d ...
- [INS-30131] 执行安装程序验证所需的初始设置失败问题解决,windows下oracle安装步骤
[INS-30131] 执行安装程序验证所需的初始设置失败问题解决,windows下oracle安装步骤 配置: 系统:windows10 数据库:Oracle Database 12c 第 1 版 ...
- plsql 连接oracle数据库的2种方式
plsql 连接oracle数据库的2种方式 CreationTime--2018年8月10日09点50分 Author:Marydon 方式一:配置tnsnames.ora 该文件在instan ...
- Oracle 创建数据库卡死在85%
Oracle 创建数据库卡死在85%处理方法 1.首先用改工具,删除数据库 2.对应的目录 3.重启服务器(本次尝试有重启,在有其他数据库在跑的情况下,可以试试不重启)
- windows下获取IP地址的两种方法
windows下获取IP地址的两种方法: 一种可以获取IPv4和IPv6,但是需要WSAStartup: 一种只能取到IPv4,但是不需要WSAStartup: 如下: 方法一:(可以获取IPv4和I ...
随机推荐
- 使用Wisdom RESTClient进行自动化测试,如何取消对返回的body内容的校验?对排除的JSON属性字段不做校验?
使用 Wisdom RESTClient 进行自动化测试 REST API,默认是对返回HTTP状态码和body内容都进行严格匹配和校验. (1). 如果每次触发API返回的body内容是动态变化的, ...
- hiho一下 第145周
题目1 : 智力竞赛 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi.小Ho还有被小Hi强拉来的小Z,准备组队参加一个智力竞赛.竞赛采用过关制,共计N个关卡.在第i ...
- Eloquent JavaScript #12# Handling Events
索引 Notes onclick removeEventListener Event objects stopPropagation event.target Default actions Key ...
- Eloquent JavaScript #05# higher-order functions
索引 Notes 高阶函数 forEach filter map reduce some findIndex 重写课本示例代码 Excercises Flattening Your own loop ...
- AngularJS中angular.min.js:80 Error: [ng:areq] http://errors.angularjs.org/1.2.9/ng/areq
报出来的时候,出现这种错误,是因为在引入控制器的时候没有引入成功,我遇到这个错误是在因为没有将父控制器引入到子控制器中.
- django 分页函数
实现类似: 上一页 1 ... 4 5 7 8 ... 89 下一页 的效果 def pageGenerate(fullList,pagenum,urltype,type,currpage): pag ...
- Prometheus监控学习笔记之PromQL操作符
0x00 二元运算符 Prometheus 的查询语言支持基本的逻辑运算和算术运算.对于两个瞬时向量, 匹配行为可以被改变. 算术二元运算符 在 Prometheus 系统中支持下面的二元算术运算符: ...
- P2590 [ZJOI2008]树的统计(树链剖分)
P2590 [ZJOI2008]树的统计 虽然是入门树剖模板 但是我终于1A了(大哭) 懒得写啥了(逃 #include<iostream> #include<cstdio> ...
- 无旋转Treap简介
无旋转Treap是一个神奇的数据结构,能够支持插入,删除,查询k大,查询某个数的排名,查询前驱后继,支持各种区间操作和持久化.基于旋转的Treap无法实现区间反转等操作,但是无旋Treap可以轻易地支 ...
- Django缓存系统
在动态网站中,用户每次请求一个页面,服务器都会执行以下操作:查询数据库,渲染模板,执行业务逻辑,最后生成用户可查看的页面. 这会消耗大量的资源,当访问用户量非常大时,就要考虑这个问题了. 缓存就是为了 ...