创建Oracle数据库
前言安装好Oracle软件是不够的,我们还需要真正在其上创建数据库后才能够正常的学习Oracle,下面来具体看一下如何建库Oracle配置助手(DatabaseConfigurationAss
前言
安装好Oracle软件是不够的,我们还需要真正在其上创建数据库后才能够正常的学习Oracle,下面来具体看一下如何建库
Oracle配置助手(Database Configuration Assistant,DBCA)是一个Oracle自带的非常方便的数据库创建工具,我们来看一下使用DBCA创建一个数据库
创建数据库
[oracle@ebs ~]$ dbca
在Oracle帐号下执行dbca命令,调出欢迎页面
出现欢迎页面后,点击下一步继续
选择创建数据库选项,点击下一步继续
根据实际需求选择数据库的类型,点击下一步继续
键入全局数据库名与ORACLE_SID名称(注:单实例模式下,全局数据库名与ORACLE_SID名称一定一致,也必须一致),点击下一步继续
暂时不配置OEM企业管理器,点击下一步继续
根据实际需求为sys用户与system用户创建口令(一定牢记),练习环境,熊熊在这里使用了统一管理口令oracle,点击下一步继续
为了方便,使用OMF管理表空间,点击下一步继续
开启快速闪回区,按默认的配置即可,点击下一步继续
练习模式增加示例方案,这样一些示例对象和库就会存在于我们创建好的数据库中,以供我们学习使用,点击下一步继续
因为11g采用了最新的内存自动管理机制(比10g的SGA自动管理还要高级),通常使用默认的40%即可
进程的话,练习有200足矣
确定字符集后,美国空间,点击下一步继续
这里可以根据实际需求改,熊熊偷懒,DBCA里的库就用默认了,点击下一步继续
勾选创建数据库,点击完成即可
确认摘要中所有内容无误后,点击确定开始正式创建数据库
至此,Oracle数据库创建完毕,点击退出按钮关闭页面
登陆上去看一下,出现上图所示结果,证明数据库创建正常
配置数据库
[oracle@ebs ~]$ dbca
在Oracle帐号下执行dbca命令,调出欢迎页面
出现欢迎页面后,点击下一步继续
选择配置数据库选件,香港服务器,点击下一步继续
选择我们刚刚创建的数据库,点击下一步继续
选择配置OEM,点击下一步继续
勾选Oracle Label Security选项,点击下一步继续
为DBSNMP与SYSMAN帐号增加密码,同样使用oracle即可,点击下一步继续
确定专用服务器连接模式(现在基本上都是专用服务器连接),点击完成
配置PL/SQL Develop工具
PL/SQL Develop是一款非常好用的集成客户端应用工具,安装好PL/SQL Develop后,需要在本地安装客户端程序,并设置好客户端连接程序后,则可以使用PL/SQL Develop连接到远程数据库
安装Oracle客户端
下载Windows版的客户端程序并解压,到client的安装目录后,双击setup图标
在安装类型中选择管理员类型,点击下一步继续
在产品语言中选择简体中文与英语,点击下一步继续
根据实际需求确定Oracle的基目录(ORACLE_BASE)与Oracle的软件位置(ORACLE_HOME),点击下一步继续
在先决条件检查里会出现一些小问题,那是因为我们没有设置参数所致,不用管它,全部忽略即可,点击下一步继续
确认无误后,点击完成开始安装
安装完毕后,点击关闭按钮关闭页面
配置PL/SQL Develop
在client的安装目录有一个network/admin目录,对应于服务器上是一样的目录结构,将服务器上的客户端连接程序(tnsnames.ora)下载一份到这个目录下
开启PL/SQL Develop工具,发现可以连接了
确定所需连接的用户名和密码,以及所需连接的数据库后,点击确定按钮
新建一个SQL窗口,随便执行一条查询语句,香港服务器租用,可以看到结果,OK,这时我们的PL/SQL已经与远端数据库正式连接。
前言
在生产环境中,经常会遇到数据库服务器没有安装X-Windows或者没有图像界面的情况,这时就需要我们使用手工脚本来创建数据库,因此会熟练的编写建库脚本,也是Oracle DBA必需的基本技术。
建库前准备
创建上图所示文件夹,用来存放各种所需的文件与脚本
配置口令文件
[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目录下,执行上述命令,编写初始化参数文件
文件内容如上图所示
编写建库脚本
[oracle@ebs dbs]$ vi /home/oracle/scripts/createDB.sql
执行上述命令,编写建库脚本
脚本内容如上图所示
编写配置脚本
建库脚本编写完毕后,还需要编写一些配置脚本,使用建库脚本创建好数据库后,还需要运行这些配置脚本,数据库才能正常工作
[oracle@ebs dbs]$ vi /home/oracle/scripts/alterDB.sql
配置脚本内容如上图所示
创建数据库
所有的准备工作准备OK后,我们开始来正式创建数据库,一起看一下
执行上图所示一系列命令来创建数据库
出现如上图所示,证明数据库创建OK
执行上述命令,开始运行配置脚本
SQL> @ ?/sqlplus/admin/pupbld.sql
SQL> @ ?/sqlplus/admin/help/hlpbld.sql helpus
执行完毕后,使用system用户登录到数据库中,执行上述两条命令,至此数据库完全创建完毕并可用
创建示例方案
首先创建两个临时表空间,并将其加入到临时表空间组中
创建好临时表空间组后,将开始执行示例方案的创建脚本
配置自动启动脚本
我们可以通过一些配置脚本,来实现Oracle的自动启动关闭功能,来看一下
[root@ebs ~]# vi /etc/oratab
编写上述文件,配置上图所示两行代码,使实例开机启动
[root@ebs ~]# vi /etc/rc.d/init.d/oracle
执行上述命令,编写自启动脚本
脚本内容如上图所示,编写完成后,不要忘了为其增加执行权限
这样就启动OK了
将其加载到启动服务中,这样每次开机,Oracle就会自动启动了
本文出自 “猫熊的幸福生活” 博客,请务必保留此出处

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The retention period of Oracle database logs depends on the log type and configuration, including: Redo logs: determined by the maximum size configured with the "LOG_ARCHIVE_DEST" parameter. Archived redo logs: Determined by the maximum size configured by the "DB_RECOVERY_FILE_DEST_SIZE" parameter. Online redo logs: not archived, lost when the database is restarted, and the retention period is consistent with the instance running time. Audit log: Configured by the "AUDIT_TRAIL" parameter, retained for 30 days by default.

Oracle database server hardware configuration requirements: Processor: multi-core, with a main frequency of at least 2.5 GHz. For large databases, 32 cores or more are recommended. Memory: At least 8GB for small databases, 16-64GB for medium sizes, up to 512GB or more for large databases or heavy workloads. Storage: SSD or NVMe disks, RAID arrays for redundancy and performance. Network: High-speed network (10GbE or higher), dedicated network card, low-latency network. Others: Stable power supply, redundant components, compatible operating system and software, heat dissipation and cooling system.

The amount of memory required by Oracle depends on database size, activity level, and required performance level: for storing data buffers, index buffers, executing SQL statements, and managing the data dictionary cache. The exact amount is affected by database size, activity level, and required performance level. Best practices include setting the appropriate SGA size, sizing SGA components, using AMM, and monitoring memory usage.

The amount of memory required for an Oracle database depends on the database size, workload type, and number of concurrent users. General recommendations: Small databases: 16-32 GB, Medium databases: 32-64 GB, Large databases: 64 GB or more. Other factors to consider include database version, memory optimization options, virtualization, and best practices (monitor memory usage, adjust allocations).

To create a scheduled task in Oracle that executes once a day, you need to perform the following three steps: Create a job. Add a subjob to the job and set its schedule expression to "INTERVAL 1 DAY". Enable the job.

Oracle Database memory requirements depend on the following factors: database size, number of active users, concurrent queries, enabled features, and system hardware configuration. Steps in determining memory requirements include determining database size, estimating the number of active users, understanding concurrent queries, considering enabled features, and examining system hardware configuration.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

Oracle listeners are used to manage client connection requests. Startup steps include: Log in to the Oracle instance. Find the listener configuration. Use the lsnrctl start command to start the listener. Use the lsnrctl status command to verify startup.
