新建Oracle数据库的3种方法
以下是对新建Oracle数据库的三种方法进行了详细的分析介绍,需要的朋友可以过来参考下 1.通过运行Oracle Database Configuration Assistant 创建、配置、或删除数据库(也可在命令行下输入dbca); 2.用命令行的方式建立数据库 3.通过运行自定义的批处理脚本(
以下是对新建Oracle数据库的三种方法进行了详细的分析介绍,,需要的朋友可以过来参考下
1.通过运行Oracle Database Configuration Assistant 创建、配置、或删除数据库(也可在命令行下输入dbca);
2.用命令行的方式建立数据库
3.通过运行自定义的批处理脚本(或create_ORACLE_SID.bat(create_ORACLE_SID.sql))来创建、配置、或删除数据库。
详述:
1.通过运行Oracle Database Configuration Assistant 创建、配置、或删除数据库;
建议不熟悉创建过程的DBA使用该方法,只需要根据选项“下一步”进行配置,最后生成数据库的创建脚本(建议保留),或者直接创建数据库;
优点:GUI方法使用方便;
缺点:不过创建过程有些慢;
2.用命令行的方式建立数据库
复制代码 代码如下:
CONNECT / AS SYSDBA
STARTUP PFILE= 'C:oracleadmininit_testorcl.ora' NOMOUNT;
CREATE DATABASE testOrcl DATAFILE '/u02/oracle/testOrcl/system01.dbf' SIZE 100M
LOGFILE GROUP1 ('/u01/oracle/testOrcl/redo1a.log',
'/u02/oracle/testOrcl/redo1b.log') SIZE 500K,
GROUP2 ('/u01/oracle/testOrcl/redo1a.log',
'/u02/oracle/testOrcl/redo1b.log') SIZE 500K
CHARACTER SET ZHS16CGB231280;
--将数据库直接从未建置状态转换到打开状态
ALTER DATABASE OPEN;
--删除数据库(Dropping a Database)
SPOOL C:DROP_DATABASE.BAT
SELECT 'DEL '||NAME 删除数据库相关数据文件 FROM V$DATAFILE;
SELECT 'DEL '||MEMBER 删除数据重构日志文件 FROM V$LOGFILE;
SPOOL OFF;
优点:可以熟悉创建指令,创建原理;
缺点:配置简单,要求熟记命令行指令;
3.通过运行自定义的批处理或SQL脚本(create_ORACLE_SID.bat或create_ORACLE_SID.sql)来创建
复制代码 代码如下:
--create_ORACLE_SID.bat
set ORACLE_SID= ORACLE_SID.
del C:ORACLE8IdatabasepwdORACLE_SID.ora
C:ORACLE8Ibinoradim -new -sid ORACLE_SID. -intpwd oracle -startmode manual
-pfile C:ORACLE8IadminORACLE_SIDpfileinit.ora
C:ORACLE8Ibinsvrmgrl @C:WINNTProfilesAdministratorLbORACLE_SIDrun.sql
C:ORACLE8Ibinsvrmgrl @C:WINNTProfilesAdministratorLbORACLE_SIDrun1.sql
C:ORACLE8Ibinoradim -edit -sid ORACLE_SID -startmode auto
--ORACLE_SIDrun.sql
spool C:ORACLE8IadminORACLE_SIDcreatecreatedb
set echo on
connect INTERNAL/oracle
startup nomount pfile=C:ORACLE8IadminORACLE_SIDpfileinit.ora
CREATE DATABASE ORACLE_SID
LOGFILE 'C:ORACLE8IoradataORACLE_SIDredo01.log' SIZE 1024K,
'C:ORACLE8IoradataORACLE_SIDredo02.log' SIZE 1024K
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXLOGHISTORY 1
DATAFILE 'C:ORACLE8IoradataORACLE_SIDsystem01.dbf' SIZE 50M REUSE
MAXDATAFILES 254
MAXINSTANCES 1
CHARACTER SET ZHT16BIG5
NATIONAL CHARACTER SET ZHT16BIG5;
spool off
--ORACLE_SIDrun1.sql
spool C:ORACLE8IadminORACLE_SIDcreatecreatedb1
set echo on
connect INTERNAL/oracle
ALTER DATABASE DATAFILE 'C:ORACLE8IoradataORACLE_SIDsystem01.dbf' AUTOEXTEND ON;
CREATE ROLLBACK SEGMENT SYSROL TABLESPACE "SYSTEM" STORAGE (INITIAL 100K NEXT 100K);
ALTER ROLLBACK SEGMENT "SYSROL" ONLINE;
Linux平台下Oracle的操作
下面对Oracle的操作都是在Linux平台下进行的!
1.su Oracle
2.sqlplus /logon
3.connect test/test assysdba(test/test是Oracle用户和密码)
4.startup
5.lsnrctl
首选启动数据库
su - Oracle
sqlplus /nolog
conn /as sysdba
startup
然后启动监听:
进入/opt/Oracle/product/9.2.0/bin/
lsnrctl start
运行shudown命令关闭数据库
[Oracle@wing /Oracle]$ sqlplus" / as sysdba" //以sysdba用户登陆数据库
SQL> shutdown
启动Oracle 9i 数据库
[Oracle@wing bin]$ sqlplus " /as sysdba"
SQL> startup
启动Oracle 9i监听程序
Oracle的监听程序主要是为客户端的连接提供接口
[Oracle@wing bin]$ lsnrctl
LSNRCTL> start
关闭Oracle 9i监听程序
[Oracle@wing bin]$ lsnrctl
LSNRCTL> stop
先看看Oracle_SID 环境变量设置是否正确。
9i:
$ sqlplus /nolog
SQL> connect / as sysdba
SQL> startup
$ lsnrctl start
8i:
$ svrmgrl
SVRMGR> connect internal
SVRMGR> startup
$ lsnrctl start
在哪里报错??
一般只要设置这2处就好了~
/etc/oratab
ora2:/Oracle/app/Oracle/product/8.1.7:Y
/etc/inittab
oralce:2:wait:/bin/su - Oracle -c '/Oracle/app/Oracle/product/8.1.7/bin/lsnrctl start'
Oracle:2:wait:/bin/su - Oracle -c '/Oracle/app/Oracle/product/8.1.7/bin/dbstart'
启动步骤:
su - Oracle
[Oracle@websvr1 Oracle]$ sqlplus /nolog
SQL> connect / as sysdba
SQL> startup
SQL> quit
[Oracle@websvr1 Oracle]$ lsnrctl start
可用 [Oracle@websvr1 Oracle]$ lsnrctl status 查看监听是否已经启动

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

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

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



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.

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.

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

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.

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

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

An AWR report is a report that displays database performance and activity snapshots. The interpretation steps include: identifying the date and time of the activity snapshot. View an overview of activities and resource consumption. Analyze session activities to find session types, resource consumption, and waiting events. Find potential performance bottlenecks such as slow SQL statements, resource contention, and I/O issues. View waiting events, identify and resolve them for performance. Analyze latch and memory usage patterns to identify memory issues that are causing performance issues.
