Home Database Mysql Tutorial 创建Oracle数据库

创建Oracle数据库

Jun 07, 2016 pm 05:41 PM
oracle database

前言安装好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 of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

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

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1242
24
MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

MySQL vs. Other Databases: Comparing the Options MySQL vs. Other Databases: Comparing the Options Apr 15, 2025 am 12:08 AM

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

What to do if the oracle log is full What to do if the oracle log is full Apr 12, 2025 am 06:09 AM

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

How to stop oracle database How to stop oracle database Apr 12, 2025 am 06:12 AM

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

See all articles