search
HomeDatabaseMysql Tutorial 创建Oracle数据库

前言安装好Oracle软件是不够的,我们还需要真正在其上创建数据库后才能够正常的学习Oracle,下面来具体看一下如何建库Oracle配置助手(DatabaseConfigurationAss

前言

安装好Oracle软件是不够的,我们还需要真正在其上创建数据库后才能够正常的学习Oracle,下面来具体看一下如何建库

Oracle配置助手(Database Configuration Assistant,DBCA)是一个Oracle自带的非常方便的数据库创建工具,我们来看一下使用DBCA创建一个数据库

创建数据库

[oracle@ebs ~]$ dbca

在Oracle帐号下执行dbca命令,调出欢迎页面

clip_image001

出现欢迎页面后,点击下一步继续

clip_image002

选择创建数据库选项,点击下一步继续

clip_image003

根据实际需求选择数据库的类型,点击下一步继续

clip_image004

键入全局数据库名与ORACLE_SID名称(注:单实例模式下,全局数据库名与ORACLE_SID名称一定一致,也必须一致),点击下一步继续

clip_image005

暂时不配置OEM企业管理器,点击下一步继续

clip_image006

根据实际需求为sys用户与system用户创建口令(一定牢记),练习环境,熊熊在这里使用了统一管理口令oracle,点击下一步继续

clip_image007

为了方便,使用OMF管理表空间,点击下一步继续

clip_image008

开启快速闪回区,按默认的配置即可,点击下一步继续

clip_image009

练习模式增加示例方案,这样一些示例对象和库就会存在于我们创建好的数据库中,以供我们学习使用,点击下一步继续

clip_image010

因为11g采用了最新的内存自动管理机制(比10g的SGA自动管理还要高级),通常使用默认的40%即可

clip_image011

进程的话,练习有200足矣

clip_image012

确定字符集后,美国空间,点击下一步继续

clip_image013

这里可以根据实际需求改,熊熊偷懒,DBCA里的库就用默认了,点击下一步继续

clip_image014

勾选创建数据库,点击完成即可

clip_image015

确认摘要中所有内容无误后,点击确定开始正式创建数据库

clip_image016

至此,Oracle数据库创建完毕,点击退出按钮关闭页面

clip_image017

登陆上去看一下,出现上图所示结果,证明数据库创建正常

配置数据库

[oracle@ebs ~]$ dbca

在Oracle帐号下执行dbca命令,调出欢迎页面

clip_image018

出现欢迎页面后,点击下一步继续

clip_image019

选择配置数据库选件,香港服务器,点击下一步继续

clip_image020

选择我们刚刚创建的数据库,点击下一步继续

clip_image021

选择配置OEM,点击下一步继续

clip_image022

勾选Oracle Label Security选项,点击下一步继续

clip_image023

为DBSNMP与SYSMAN帐号增加密码,同样使用oracle即可,点击下一步继续

clip_image024

确定专用服务器连接模式(现在基本上都是专用服务器连接),点击完成

配置PL/SQL Develop工具

PL/SQL Develop是一款非常好用的集成客户端应用工具,安装好PL/SQL Develop后,需要在本地安装客户端程序,并设置好客户端连接程序后,则可以使用PL/SQL Develop连接到远程数据库

安装Oracle客户端

下载Windows版的客户端程序并解压,到client的安装目录后,双击setup图标

clip_image025

在安装类型中选择管理员类型,点击下一步继续

clip_image026

在产品语言中选择简体中文与英语,点击下一步继续

clip_image027

根据实际需求确定Oracle的基目录(ORACLE_BASE)与Oracle的软件位置(ORACLE_HOME),点击下一步继续

clip_image029

在先决条件检查里会出现一些小问题,那是因为我们没有设置参数所致,不用管它,全部忽略即可,点击下一步继续

clip_image030

确认无误后,点击完成开始安装

clip_image031

安装完毕后,点击关闭按钮关闭页面

配置PL/SQL Develop

在client的安装目录有一个network/admin目录,对应于服务器上是一样的目录结构,将服务器上的客户端连接程序(tnsnames.ora)下载一份到这个目录下

开启PL/SQL Develop工具,发现可以连接了

clip_image033

确定所需连接的用户名和密码,以及所需连接的数据库后,点击确定按钮

clip_image034

新建一个SQL窗口,随便执行一条查询语句,香港服务器租用,可以看到结果,OK,这时我们的PL/SQL已经与远端数据库正式连接。

前言

在生产环境中,经常会遇到数据库服务器没有安装X-Windows或者没有图像界面的情况,这时就需要我们使用手工脚本来创建数据库,因此会熟练的编写建库脚本,也是Oracle DBA必需的基本技术。

建库前准备

clip_image001[4]

创建上图所示文件夹,用来存放各种所需的文件与脚本

配置口令文件

[oracle@ebs dbs]$ orapwd file=orapwprod password=oracle entries=20

在ORACLE_HOME的dbs目录下,执行上述命令,生成口令文件;其中file的命名格式为orapwSID,password即为sys用户的密码,entries则为允许连接sys用户的最大值(默认为0,即无限制)

编写初始化参数文件

[oracle@ebs dbs]$ vi initprod.ora

在ORACLE_HOME的dbs目录下,执行上述命令,编写初始化参数文件

clip_image002[4]

文件内容如上图所示

编写建库脚本

[oracle@ebs dbs]$ vi /home/oracle/scripts/createDB.sql

执行上述命令,编写建库脚本

clip_image003[4]

脚本内容如上图所示

编写配置脚本

建库脚本编写完毕后,还需要编写一些配置脚本,使用建库脚本创建好数据库后,还需要运行这些配置脚本,数据库才能正常工作

[oracle@ebs dbs]$ vi /home/oracle/scripts/alterDB.sql

clip_image004[4]

配置脚本内容如上图所示

创建数据库

所有的准备工作准备OK后,我们开始来正式创建数据库,一起看一下

clip_image005[4]

执行上图所示一系列命令来创建数据库

clip_image006[4]

出现如上图所示,证明数据库创建OK

执行上述命令,开始运行配置脚本

SQL> @ ?/sqlplus/admin/pupbld.sql

SQL> @ ?/sqlplus/admin/help/hlpbld.sql helpus

执行完毕后,使用system用户登录到数据库中,执行上述两条命令,至此数据库完全创建完毕并可用

创建示例方案

首先创建两个临时表空间,并将其加入到临时表空间组中

clip_image008[4]

创建好临时表空间组后,将开始执行示例方案的创建脚本

配置自动启动脚本

我们可以通过一些配置脚本,来实现Oracle的自动启动关闭功能,来看一下

[root@ebs ~]# vi /etc/oratab

编写上述文件,配置上图所示两行代码,使实例开机启动

[root@ebs ~]# vi /etc/rc.d/init.d/oracle

执行上述命令,编写自启动脚本

clip_image011[4]

脚本内容如上图所示,编写完成后,不要忘了为其增加执行权限

clip_image012[4]

这样就启动OK了

将其加载到启动服务中,这样每次开机,Oracle就会自动启动了

本文出自 “猫熊的幸福生活” 博客,请务必保留此出处

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL String Types: Storage, Performance, and Best PracticesMySQL String Types: Storage, Performance, and Best PracticesMay 10, 2025 am 12:02 AM

MySQLstringtypesimpactstorageandperformanceasfollows:1)CHARisfixed-length,alwaysusingthesamestoragespace,whichcanbefasterbutlessspace-efficient.2)VARCHARisvariable-length,morespace-efficientbutpotentiallyslower.3)TEXTisforlargetext,storedoutsiderows,

Understanding MySQL String Types: VARCHAR, TEXT, CHAR, and MoreUnderstanding MySQL String Types: VARCHAR, TEXT, CHAR, and MoreMay 10, 2025 am 12:02 AM

MySQLstringtypesincludeVARCHAR,TEXT,CHAR,ENUM,andSET.1)VARCHARisversatileforvariable-lengthstringsuptoaspecifiedlimit.2)TEXTisidealforlargetextstoragewithoutadefinedlength.3)CHARisfixed-length,suitableforconsistentdatalikecodes.4)ENUMenforcesdatainte

What are the String Data Types in MySQL?What are the String Data Types in MySQL?May 10, 2025 am 12:01 AM

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

How to Grant Permissions to New MySQL UsersHow to Grant Permissions to New MySQL UsersMay 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

How to Add Users in MySQL: A Step-by-Step GuideHow to Add Users in MySQL: A Step-by-Step GuideMay 09, 2025 am 12:14 AM

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

MySQL: Adding a new user with complex permissionsMySQL: Adding a new user with complex permissionsMay 09, 2025 am 12:09 AM

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

MySQL: String Data Types and CollationsMySQL: String Data Types and CollationsMay 09, 2025 am 12:08 AM

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

MySQL: What length should I use for VARCHARs?MySQL: What length should I use for VARCHARs?May 09, 2025 am 12:06 AM

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor