oracle数据库的使用及安装

来源:互联网 发布:中国网络直播平台排名 编辑:程序博客网 时间:2024/06/14 18:41

Oracle端口:

1521端口:oracle数据库默认端口

1158端口:oracle emctl默认端口

8080端口:oracle XDB (XML)

210端口:oracle XDB FTP服务



Windows平台下命令行oracle的使用操作:


1. 启动与停止oracle服务器

set oracle_sid=orcl
emctl stop dbconsole
emctl start dbconsole


启动与停止OracleServiceORCL

net start OracleServiceORCL

net stop OracleServiceORCL


2. 启动与停止监听

lsnrctl start

lsnrctl stop

在%ORACLE_HOME%\dbhome_1\NETWORK\ADMIN下有listener.ora,tnsnames.ora等配置下的监听端口,服务器,服务提供商等


3. 以某一用户名及密码进入sql

sqlplus username/password@net_service_name
sqlplus username/password
sqlplus sys/password@net_service_name as sysdba
sqlplus sys/password as sysdba
sqlplus / as sysdba

参考:http://www.adp-gmbh.ch/ora/sqlplus/index.html


4. 进入sql后的一些操作:

显示参数: show parameter processes

修改参数: alter system set open_cursors=600 scope=SPFILE(MEMORY/BOTH)

参考:http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm

修改之后重启的是instance,之后才能生效

net start OracleServiceORCL

net stop OracleServiceORCL


一些操作在win 7下因为权限问题cmd窗口无法执行,需要进入管理员的cmd窗口,方式如下:

Press Start button > go to Accessories > right-click Command Prompt > select "Run as administrator"


特别要注意的是,进入sql后执行select等语句后注意语句结尾要有;号,否则将返回2使得查询失败。


5. 删除数据库

进入“运行”窗口,敲打cmd命令后在dos界面运行DBCA,删除数据库。

C:\app\zhatan\product\11.2.0\dbhome_1\deinstall卸载


2012-7-17

今天把C:\app\zhatan\oradata\orcl下的文件删除了,结果出错“all appropriate instances are blocking new connections", 尝试很多办法都不行。后来进入到https://localhost:1158/em中发现能够显示orcl无法连接,启动错误是少了CONTROL01.CTL。实在没办法了,暂时将C:\app\zhatan\flash_recovery_area\orcl的CONTROL02.CTL拷贝过来。于是又出现新错误,少了许多其他的文件。


2012-7-18

补充概念:

Instance, Database and Schema

Instance, Database and Schema: The distinction between these three is probably one of the most confusing concepts across different RDBMS since different RDBMS have different architectures and different terminologies.  To put it simply in Oracle lingo, a database is a set of files (data files, redo log files, control files and so on).  An instance is a set of processes (SMON, PMON, MMON, DBWR, etc) and a shared memory segment (SGA).  A database may be mounted and opened by many instances (RAC installation) concurrently (this is to do with the shared everything architecture of Oracle RAC).  An instance may mount and open any database — however it may only open a single database at any time.  So, in ERD terms: Database:Instance :: 1:N (a one to many relationship) in Oracle.  A schema is the container of the schema objects so all the tables, views, procedures, packages, views etc. reside in the schema.  There can be multiple schemas per database.

In the case of DB2 and SQL Server, an instance can have many databases which internally can have many schemas.  In the case of Informix, an instance can have many databases and there is no concept of schemas.  For the sake of simplicity, we refer a database as the container for the different schemas and a schema to be the one that contains all the schema objects (tables, views, procedures, packages, sequences etc.).

http://decipherinfosys.wordpress.com/2007/03/08/instance-database-and-schema/



------------------------------------------------------------------------------------------------------

Oracle在linux下的安装


1. 下载两个包

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

Linux x86-64 

2. 解压缩

unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip

3. 运行runInstaller

./runInstaller

弹出一个安装的图形化界面


数据库ctrl console (注意https)

https://localhost:1158/em


对于linux,会发现一些命令找不到(没有设置路径),这时候可以用:

set ORACLE_HOME ***/dbhome_1

$ORACLE_HOME/bin/sqlplus (或者其他命令)
$ORACLE_HOME/bin/sqlplus sys/passwd@localhost/orcl.us.oracle.com as sysdba


启动与关闭服务如果出错了就直接用https://localhost:1158/em


启动ORACLE步骤:

1. 切换到bash环境下

2. export ORACLE_UNQNAME=orcl

3. emctl start dbconsole (emctl不行的话加路径$ORACLE_HOME/bin)

4. 登陆到em来启动