Oracle数据库几个基本操作(以9.2为例)

前段时间遇到一个关于 Oracle 的案子,头一次接触 Oracle ,遇到不少问题。特总结如下,将来如有人遇到相同情形,希望本文能在入门时提供一点小小帮助。

一、 安装

a)         装过程中可能会出现的问题,需要预先处理:

                        i.              “无法在环境变量path 中插入”的错误(错误内容记不清了,大致这个意思):右击“我的电脑” à “属性” à “高级” à “环境变量” à 在下面的选择框中选中“Path à “编辑” à 检查字符串长度是否超过1024 à 删除不必要的路径 à 保存。(此变量 定义了用户执行的命令在系统中的查找顺序,也就是说。例如你可以在命令行中输入 IMP Oracle 恢复备份)命令,系统会在 Path 包含的路径中查找命令文件,找到则运行,找不到则报错

                      ii.              hostdef 不存在”的错误:Oraclewin200 安装结束后(具体在安装全局数据库结束后),会自动启动例程并作基本配置,此时会出现此错误,解决方法:安装过程中检查有否产生“oracle/ora90/network/ADMIN/sqlnet.ora ”文件 à 一旦发现生成该文件,使用记事本或UltraEdit 打开 à "SQLNET.AUTHENTICATION_SERVICES=(NTS)" 修改为"SQLNET.AUTHENTICATION_SERVICES=(NONE)"

b)        安装程序本身没太多好说的,一切按默认,过程中会要求输入一个全局数据库名作为默认库,这是唯一需要修改的地方

二、 卸载

a)         先使用 oracle 自带的卸载程序卸载。但它不会删除原 oracle 的相关配置,也不会删除数据库以及几项基本服务。所以当这些部分有错误时,哪怕重新安装也无法纠正这些错误。我们需要一下步骤彻底清除 oracle.

b)        停止所有Oracle 相关服务;

c)         删除Oracle 安装目录

d)        删除C:/Program/Oracle 目录;

e)         删除注册表相关信息:

HKLM/SoftWare/Oracle

HKLM/System/CurrentContralSet/Service/Ora ……

HKLM/System/ControlSet001/Service/Ora ……

HKLM/System/ControlSet002/Service/Ora

f)   重新启动计算机

三、 配置

a)   安装结束后应先对Oracle 进行配置(包括建立一个管理资料库),否则无法进行大部分数据库操作。

 

启动“开始菜单” à Oracle 程序组” à Configuration and Migration Tools à Enterprise Manager Configuration Assistant

 

步骤2

 

步骤3

 

 

步骤4

 

 

步骤5

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt; mso-ascii-font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-hansi-font-family:"Times New Roman"; mso-font-kerning:0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:817110624; mso-list-type:hybrid; mso-list-template-ids:331890388 838512750 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-number-format:japanese-counting; mso-level-text:%1、; mso-level-tab-stop:21.0pt; mso-level-number-position:left; margin-left:21.0pt; text-indent:-21.0pt;} @list l0:level2 {mso-level-number-format:alpha-lower; mso-level-text:"%2/)"; mso-level-tab-stop:42.0pt; mso-level-number-position:left; margin-left:42.0pt; text-indent:-21.0pt;} @list l0:level3 {mso-level-number-format:roman-lower; mso-level-tab-stop:42.3pt; mso-level-number-position:right; margin-left:42.3pt; text-indent:-21.0pt;} @list l0:level4 {mso-level-tab-stop:84.0pt; mso-level-number-position:left; margin-left:84.0pt; text-indent:-21.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

   i.      请记录以下两个口令和ID:

1.   SYS/Change_on_install

2.   system/manager

 

 

 

步骤6

<!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt; mso-ascii-font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-hansi-font-family:"Times New Roman"; mso-font-kerning:0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> 在“控制面板” à “管理工具” à “服务”中,启动“OracleOraHome90ManagementServer ”服务。(名字中的“OraHome90 ”子串由安装时输入的主路径名决定,所以也许会有不同)

<!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt; mso-ascii-font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-hansi-font-family:"Times New Roman"; mso-font-kerning:0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:817110624; mso-list-type:hybrid; mso-list-template-ids:331890388 838512750 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-number-format:japanese-counting; mso-level-text:%1、; mso-level-tab-stop:21.0pt; mso-level-number-position:left; margin-left:21.0pt; text-indent:-21.0pt;} @list l0:level2 {mso-level-number-format:alpha-lower; mso-level-text:"%2/)"; mso-level-tab-stop:42.0pt; mso-level-number-position:left; margin-left:42.0pt; text-indent:-21.0pt;} @list l0:level3 {mso-level-number-format:roman-lower; mso-level-tab-stop:42.3pt; mso-level-number-position:right; margin-left:42.3pt; text-indent:-21.0pt;} @list l0:level4 {mso-level-tab-stop:84.0pt; mso-level-number-position:left; margin-left:84.0pt; text-indent:-21.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

一、 新建用户

a)   启动“Enterprise Manager Console à “独立启动” à 点击“OEMREP ”数据库,第一次登陆使用用户:sysman ,口令:oem_temp

b)   在“OEMREP ”数据库中 à “安全性” à “用户” à 右键创建;

c)   Oracle 对用户权限分配非常详细,下面以创建一个拥有备份及恢复数据权限的用户为例演示权限分配:

   i.      新建用户后 à 选中该用户 à 选中“角色”选项卡 à 赋予其“EXP_FULL_DATABASE ”、“IMP_FULL_DATABASE ”、[DBA ”角色] à “管理选项”、“默认值”打勾

  ii.      在操作系统(win2000,winXP )中添加一个同名用户

iii.      “控制面板” à “管理工具” à “本地安全策略” à “本地策略” à “用户权利指派” à 双击“作为批处理作业登录” à “添加” à 选择该用户加入。

  iv.      重新打开“Enterprise Manager Console à 以用户:sysman, 口令:OEM_TEMP, 登陆到“Oracle Managerment Server ”(第一次登陆会要求输入服务器地址:127.0.0.1 ;以及更换口令) à 菜单栏“配置” à “首选身份证明”页签 à 选中节点 à 添加该用户。

二、 Oracle 中使用SQl ,使用“Application Development à SQL Plus

三、 备份及恢复备份

a)   备份

   i.      键入命林“Exp à 按提示键入用户名、数据库、口令

  ii.      可在键入用户时输入“用户名@ 数据库”例如“system @jiangbo ”,或“用户名/ 口令@ 数据库”例如“system/manager @jiangbo

iii.      按提示输入缓冲区大小(输大点)

  iv.      默认备份输出在Oracle/ora90/bin 目录下

b)   恢复备份

   i.      注意应建一个用户,同名于导出备份的用户。否则在A 用户导出数据,再使用B 用户导入时可能会报错。默认导出的备份会以用户名+ 其他后缀命名,导出的日志中也可查到导出的用户

  ii.      cmd 中键入IMP 命令 à 按提示键入用户名、数据库、口令

iii.      以下同于备份操作。

四、 Oracle 的数据库包含若干表空间(如System 表空间、User 表空间、Normal 表空间等等),数据表可选择保存于不同表空间中。

五、 除了下SQL ,也可通过“Enterprise Manager Console ”中的数据库 à 右击 à “查找数据对象”来查找表、函数等等。

在程序中可使用普通Ado 控件来操作Oracle 数据库。但调用存储过程则无法象SQL Server 一样下SQL ,需使用TDSADOStoredProc 控件。

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值