当前位置: 首页 > news >正文

windows平台上 oracle简单操作手册

一 环境描述

Oracle 11g单机环境

二 基本操作

2.1 数据库的启动与停止

启动:
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期五 7月 31 12:19:51 2020
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
停止:
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。

点击开始-管理工具-服务
image.png
数据库以及监听运行服务
image.png

2.2 监听的启动与停止

C:\Users\Administrator>lsnrctl start
C:\Users\Administrator>lsnrctl stopC:\Users\Administrator>lsnrctl status   //查看状态
LSNRCTL for 64-bit Windows: Version 11.2.0.4.0 - Production on 31-7月 -2020 14:0
0:46
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WIN-D30A3J59LLL.lan)(PORT=1
521)))
LISTENER 的 STATUS
------------------------
别名                      LISTENER
版本                      TNSLSNR for 64-bit Windows: Version 11.2.0.4.0 - Produ
ction
启动日期                  31-7月 -2020 13:54:16
正常运行时间              0 天 0 小时 6 分 34 秒
跟踪级别                  off
安全性                    ON: Local OS Authentication
SNMP                     OFF
监听程序参数文件          C:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
监听程序日志文件          
C:\app\Administrator\diag\tnslsnr\WIN-D30A3J59LLL\listener\alert\log.xml
监听端点概要...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=WIN-D30A3J59LLL)(PORT=1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
服务摘要..
服务 "CLRExtProc" 包含 1 个实例。实例 "CLRExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
服务 "orcl" 包含 1 个实例。实例 "orcl", 状态 READY, 包含此服务的 1 个处理程序...
服务 "orclXDB" 包含 1 个实例。实例 "orcl", 状态 READY, 包含此服务的 1 个处理程序...
命令执行成功

2.3 如何连接数据库

(包括如何设置环境变量,如何连接,如何查看监听服务)
(1)临时指定变量ORACLE_SID

C:\Users\Administrator>set ORACLE_SID=orcl
C:\Users\Administrator>set ORACLE_SID
ORACLE_SID=orcl
连接
C:\Users\Administrator>sqlplus / as sysdba

查询连接信息

SQL> select instance_name,status from v$instance;INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPENSQL> select name from v$database;NAME
---------
ORCL

(2)设置系统变量

找到计算机-右键-点击属性
image.png
点击高级系统设置:
image.png
选择高级-环境变量
image.png
点击新建:
image.png
点击确定
查看:
C:\Users\Administrator>set ORACLE_SID
ORACLE_SID=orcl
连接
C:\Users\Administrator>sqlplus / as sysdba

2.4 用户与表空间的创建

创建用户:

SYS@orcl11g> CREATE USER user01 IDENTIFIED BY user01      --创建密码DEFAULT TABLESPACE users  --创建用户使用默认的表空间TEMPORARY TABLESPACE temp --指定用户默认使用的临时表空间

创建表空间:

SQL> create tablespace tbs01
datafile '/u01/app/oracle/oradata/orcl11g/tbs01.dbf' 
size 1G
autoextend on 

向表空间中添加数据文件:

SQL> alter tablespace tbs01
add datafile '/u01/app/oracle/oradata/orcl11g/tbs02.dbf'
size 1G 
autoextend on

2.5 查看操作系统日志、数据库日志

(1)查看操作系统日志:
开始-管理工具-事件查看器
image.png
(2)数据库警告日志位置:
$ORACLE_BASE\diag\rdbms\orcl\orcl\trace
C:\app\Administrator\diag\rdbms\orcl\orcl\trace
image.png

2.5 windows清理监听日志

(1)清理监听日志:

找到存放位置
C:\app\Administrator\diag\tnslsnr\WIN-D30A3J59LLL\listener\trace\listener清理监听日志:
C:\Users\Administrator>cd C:\app\Administrator\diag\tnslsnr\ WIN-D30A3J59LLL \listener\trace
C:\Users\Administrator>echo “ “ > listener.log

(2)关闭监听日志写功能:

C:\Users\Administrator>lsnrctl
LSNRCTL for 64-bit Windows: Version 11.2.0.4.0 - Production on 31-7月 -2020 14:3
6:14Copyright (c) 1991, 2013, Oracle.  All rights reserved.
欢迎来到LSNRCTL, 请键入"help"以获得信息。LSNRCTL> set log_status off
正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WIN-D30A3J59LLL.lan)(PORT=1521)))
LISTENER 参数 "log_status" 设为 OFF
命令执行成功LSNRCTL> save_config
正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WIN-D30A3J59LLL.lan)(PORT=1521)))
保存的LISTENER配置参数。
监听程序参数文件          C:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\A
DMIN\listener.ora
旧的参数文件C:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.
bak
命令执行成功

再次查看监听状态:

C:\Users\Administrator>lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.4.0 - Production on 31-7月 -2020 14:
8:18
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WIN-D30A3J59LLL.lan)(PORT=1521)))
LISTENER 的 STATUS
------------------------
别名                      LISTENER
版本                      TNSLSNR for 64-bit Windows: Version 11.2.0.4.0 - Prod
ction
启动日期                  31-7月 -2020 13:54:16
正常运行时间              0 天 0 小时 44 分 6 秒
跟踪级别                  off
安全性                    ON: Local OS Authentication
SNMP                     OFF
监听程序参数文件          C:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\
DMIN\listener.ora
监听端点概要...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=WIN-D30A3J59LLL)(PORT=1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
服务摘要..
服务 "CLRExtProc" 包含 1 个实例。实例 "CLRExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
服务 "orcl" 包含 1 个实例。实例 "orcl", 状态 READY, 包含此服务的 1 个处理程序...
服务 "orclXDB" 包含 1 个实例。实例 "orcl", 状态 READY, 包含此服务的 1 个处理程序...
命令执行成功
//已无日志文件显示

2.6 查看windows系统资源使用

任务管理器
image.png

image.png
点击资源监视器查看其他资源信息
image.png

2.7 日常维护命令

性能查看:

查看等待事件:
SYS@prod>select event,count(*) from gv$session_wait where wait_class<>'Idle' group by event;查看资源使用情况:
SYS@prod>select * from v$resource_limit;

表空间使用率查看

col tablespace_name format a8col status format a7col extent_management format a5col segment_space_management format a6col contents format a9select tpsname,status,mgr,maxsize,c_userd,max_used  from (SELECT  d.tablespace_name  tpsname,d.status status,d.segment_space_management mgr, d.contents type,TO_CHAR(NVL(trunc(A.maxbytes / 1024 / 1024), 0),'99G999G990') maxsize,TO_CHAR(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0),'990D00') c_userd,TO_CHAR(NVL((a.bytes - NVL(f.bytes, 0)) / a.maxbytes * 100, 0),'990D00') max_usedFROM sys.dba_tablespaces d,(SELECT tablespace_name,sum(bytes) bytes,SUM(case autoextensible when  'NO'  then BYTES when  'YES' then MAXBYTES else null end ) maxbytes   FROM dba_data_files  GROUP BY tablespace_name) a,(SELECT tablespace_name,SUM(bytes) bytes, MAX(bytes) largest_free   FROM dba_free_space   GROUP BY tablespace_name) f  WHERE d.tablespace_name = a.tablespace_name   AND d.tablespace_name = f.tablespace_name(+))where max_used>0order by max_used desc;MAX_USED列不要超过百分之90

2.8获取AWR报告

SQL> @?/rdbms/admin/awrrpt.sql

Current Instance
~~~~~~~~~~~~~~~~DB Id    DB Name      Inst Num Instance
----------- ------------ -------- ------------1574596224 ORCL                1 orclSpecify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Would you like an HTML report, or a plain text report?
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'
输入 report_type 的值:  htmlType Specified:  htmlInstances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~DB Id     Inst Num DB Name      Instance     Host
------------ -------- ------------ ------------ ------------
* 1574596224        1 ORCL         orcl         WIN-D30A3J59LLLUsing 1574596224 for database Id
Using          1 for instance numberSpecify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed.  Pressing <return> without
specifying a number lists all completed snapshots.输入 num_days 的值:  2    //显示几天内的Listing the last 2 days of Completed SnapshotsSnap
Instance     DB Name        Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
orcl         ORCL                 7 31 7月  2020 11:36     18 31 7月  2020 14:09     19 31 7月  2020 15:00     1Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
输入 begin_snap 的值:  8
Begin Snapshot Id specified: 8输入 end_snap 的值:  9
End   Snapshot Id specified: 9Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_8_9.html.  To use this name,
press <return> to continue, otherwise enter an alternative.输入 report_name 的值:  C:\awrrpt_1_8_9.html
Using the report name C:\awrrpt_1_8_9.html
Report written to C:\awrrpt_1_8_9.htmlAWR报告的位置:
C:\awrrpt_1_8_9.html

hhh6.jpg

http://www.lryc.cn/news/537215.html

相关文章:

  • 【网络安全 | 漏洞挖掘】价值3133美元的Google IDOR
  • LabVIEW太阳能制冷监控系统
  • 10.2 Git 内部原理 - Git 对象
  • 作业。。。。。
  • android 的抓包工具
  • 深入剖析推理模型:从DeepSeek R1看LLM推理能力构建与优化
  • linux中top命令详解
  • 前端包管理器的发展以及Npm、Yarn和Pnpm对比
  • node.js+兰空图床实现随机图
  • 【MySQL】高频 SQL 50 题(基础版)
  • 盛铂科技 SMF106 低相位噪声贴片式频率综合器模块
  • C语言如何实现面向对象?——从结构体到自由函数的思考
  • 深入探索C语言中的字符串处理函数:strstr与strtok
  • 浅聊Docker使用、部署
  • jenkins war Windows安装
  • 学习数据结构(9)栈和队列上
  • 【git-hub项目:YOLOs-CPP】本地实现03:跑自己的实例分割模型
  • MySQL和SQL server的区别
  • C#运动控制——轴IO映射
  • DeepSeek官方发布R1模型推荐设置
  • DeepSeek教unity------MessagePack-03
  • 《安富莱嵌入式周报》第350期:Google开源Pebble智能手表,开源模块化机器人平台,开源万用表,支持10GHz HRTIM的单片机,开源CNC控制器
  • img标签的title和alt
  • MambaMorph brain MR-CT
  • 小米 R3G 路由器(Pandavan)实现网络打印机功能
  • Python PyCharm DeepSeek接入
  • 【ISO 14229-1:2023 UDS诊断全量测试用例清单系列:第二十节】
  • jemalloc 5.3.0的base模块的源码及调用链使用场景的详细分析
  • ThreadLocal源码分析
  • Python爬虫实战:获取笔趣阁图书信息,并做数据分析