编译oraclereport
A. 如何生成Oracle AWR报告
首先进入$ORACLE_HOME/rdbms/admin目录,在sqlplus下运行@awrrpt脚本,按照提示一步一步就可以达成,导出的格式有两种,txt格式和html格式。
在OTN上,有一个DBA新feature系列,第六周就是专门讲的这个feature,大家可以去那里了解一下(中文的)
Script started on Sun 27 Jan 2008 08:47:15 PM PST
[ractest@sun880-1 /u01/app/oracle/orahome/rdbms/admin]$ cd $ORACLE_HOME/rdbms/admin
[ractest@sun880-1 /u01/app/oracle/orahome/rdbms/admin]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Proction on Sun Jan 27 20:47:38 2008
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Proction
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> @awrrpt
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
———– ———— ——– ————
2080780909 ORCLDB 1 orcldb1
Specify 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’
Enter value for report_type: text
Type Specified: text
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
———— ——– ———— ———— ————
* 2080780909 1 ORCLDB orcldb1 sun880-1
2080780909 4 ORCLDB orcldb4 sun880-4
2080780909 2 ORCLDB orcldb2 sun880-2
2080780909 3 ORCLDB orcldb3 sun880-3
Using 2080780909 for database Id
Using 1 for instance number
Specify 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 without
specifying a number lists all completed snapshots.
Enter value for num_days: 1
Listing the last day’s Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
———— ———— ——— —————— —–
orcldb1 ORCLDB 66 27 Jan 2008 00:55 1
67 27 Jan 2008 01:55 1
68 27 Jan 2008 02:55 1
69 27 Jan 2008 03:55 1
70 27 Jan 2008 04:55 1
71 27 Jan 2008 05:55 1
72 27 Jan 2008 06:55 1
73 27 Jan 2008 07:55 1
74 27 Jan 2008 08:55 1
75 27 Jan 2008 09:55 1
76 27 Jan 2008 10:55 1
77 27 Jan 2008 11:55 1
78 27 Jan 2008 12:55 1
83 27 Jan 2008 17:54 1
84 27 Jan 2008 18:55 1
85 27 Jan 2008 19:55 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 70
Begin Snapshot Id specified: 70
Enter value for end_snap: 71
End Snapshot Id specified: 71
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_70_71.txt. To use this name,
press to continue, otherwise enter an alternative.
Enter value for report_name:
Using the report name awrrpt_1_70_71.txt
WORKLOAD REPOSITORY report for
DB Name DB Id Instance Inst Num Release RAC Host
———— ———– ———— ——– ———– — ————
ORCLDB 2080780909 orcldb1 1 10.2.0.4.0 YES sun880-1
Snap Id Snap Time Sessions Curs/Sess
——— ——————- ——– ———
Begin Snap: 70 27-Jan-08 04:55:07 136 16.2
End Snap: 71 27-Jan-08 05:55:21 141 16.5
Elapsed: 60.23 (mins)
DB Time: 5,814.07 (mins)
Cache Sizes
~~~~~~~~~~~ Begin End
//此处有删减
————————————————————-
End of Report
Report written to awrrpt_1_70_71.txt
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Proction
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
[ractest@sun880-1 /u01/app/oracle/orahome/rdbms/admin]$ exit
script done on Sun 27 Jan 2008 08:48:16 PM PST
B. 如何生成Oracle AWR报告
1、运行,cmd。然后进入到 oracle的安装目录,这里以我的电脑为例: E:\app\Administrator\proct\11.2.0\dbhome_1\
2、再进入到下面的目录 RDBMS\ADMIN。确保E:\app\Administrator\proct\11.2.0\dbhome_1\RDBMS\ADMIN 下面有 awrrpt.sql这个文件
3、输入 sqlplus ,然后以管理员身份登录。
4、输入命名:@awrrpt
5、开始按提示操作,首先是选择要生成的awr报告的类型,可以选择text或html类型。这里我们以 html类型为例。输入 html,回画
6、选择要生成的报告的日期是在多少天以前记录,输入1,则表示要生成今天0点开始到现在之内的某个时间段的报告,输入2,则表示满意生成昨天0点开始到现在的某个时间段的报告。以此类推。缺省记录最近7天,这里输入法为示例。
7、输入天数后,界面会输出一个时间段的表格,每个时间点都对应一个snapId,间隔时间为oracle默认是1个小时,接下来,输入要生成报告的时间开始点应的snap id,这里我输入3318, 然后再输入结束点对应的snap id,这里输入 3320.
8、接着要求输入生成报告的名字,系统会自动生成一个输入的名字并会提示信息中显示出来。如果使用输入名称。则不用输入任何内容。直接回画即可。到此。系统就会自动生成一张awr的报告。
C. 如何从Oracle的FORM中调用REPORT
在菜单中调用REPORT程序(不传参数,传参数可用下面的程序段)Run_Proct(REPORTS, ’报表程序名.REP’, SYNCHRONOUS, RUNTIME, FILESYSTEM, ’’, NULL);在FORM中调用REPORT程序(可传参数)DECLARE pl_id ParamList;BEGIN pl_id := Get_Parameter_List(’参数列表名’); IF NOT Id_Null(pl_id) THEN Destroy_Parameter_List( pl_id ); END IF; pl_id := Create_Parameter_List(’参数列表名’); Add_Parameter(pl_id,’REPORT参数名1’,DATA_PARAMETER,’:FORM项名1’); Add_Parameter(pl_id,’REPORT参数名2’,TEXT_PARAMETER,’:FORM项名2’); …… Run_Proct(REPORTS, ’报表程序名.REP’, SYNCHRONOUS, RUNTIME, FILESYSTEM, pl_id, NULL);END;在报表中使用参数作为帮定变量时在其前面加一个冒号(:),如:有一个参数p_deptno,传来的值为10,则select * form emp where deptno=:p_deptno将返回表emp中deptno为10的记录。在报表中使用参数作为词汇参数时在起前面加一个“与”符号(&),如:有一个参数p_where,传来的值为where deptno=10,则select * from emp &p_where也将返回表emp中deptno为10的记录。在调用REPORT时,去掉report server:Add_parameter(pl_id,’ORACLE_SHUTDOWN’,TEXT_PARAMETER,’YES’);调用REPORT时,使报表结果直接输出到打印机上:Add_parameter(pl_id,’PSRAMETER_FORM’,TEXT_PARAMETER,’NO’);调用REPORT时,不弹出参数窗口:add_parameter(pl_id,’PARAMFORM’,TEXT_PARAMETER,’NO’); 调用REPORT时,以满屏方式显示:add_parameter(pl_id, ’maximize’, TEXT_PARAMETER,’yes’);
D. ORACLE 过程编译错误,高手来解答!
凭感觉,你的语法没错。今天连不起公司服务器。周一连上给你试试,等着。。
我们创建的时候,用的是create or replace package。我将你包的内容改变了(因为我没有创建你的那个数据表emp),运行成功了的。内容如下:
create or replace package xxemp_pkg is
procere update_sal(name varchar2,newsal number);
function annual_income(name varchar2) return number;
end;
/
create or replace package body xxemp_pkg is
procere update_sal(name varchar2,newsal number)
is
begin
/*update emp set sal=newsal
where lower(ename)=lower(name);*/null;
end;
function annual_income(name varchar2) return number
is
annual_salary number(7,2);
begin
/*select sal*12+nvl(comm,0) into annual_salary
from emp where lower(ename)=lower(name);*/null;
return annual_salary;
end;
end;
/
你再到你的系统试一试。
E. oracle中自定义的函数怎么编译
可在第三方软件中,如pl/sql中编译。
1、打开pl/sql软件并登录到指定数据库。
2、点击左上方像纸片的按钮,然后点击“sql窗口”
F. 如何生成Oracle AWR报告
Oracle性能分析入门学习中,遇到Oracle数据库的性能问题,一般首要的步骤就是导出AWR的分析报告,AWR是10g中新引入的一个工具,在这之前一般是利用statspack。要导出AWR报告,只要利用Oracle的一个脚本即可以完成,下面是我利用script录制的一段导出AWR report的过程。
首先进入$ORACLE_HOME/rdbms/admin目录,在sqlplus下运行@awrrpt脚本,按照提示一步一步就可以达成,导出的格式有两种,txt格式和html格式。
在OTN上,有一个DBA新feature系列,第六周就是专门讲的这个feature,大家可以去那里了解一下(中文的)
Script started on Sun 27 Jan 2008 08:47:15 PM PST
[ractest@sun880-1 /u01/app/oracle/orahome/rdbms/admin]$ cd $ORACLE_HOME/rdbms/admin
[ractest@sun880-1 /u01/app/oracle/orahome/rdbms/admin]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Proction on Sun Jan 27 20:47:38 2008
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Proction
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> @awrrpt
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
———– ———— ——– ————
2080780909 ORCLDB 1 orcldb1
Specify 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’
Enter value for report_type: text
Type Specified: text
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
———— ——– ———— ———— ————
* 2080780909 1 ORCLDB orcldb1 sun880-1
2080780909 4 ORCLDB orcldb4 sun880-4
2080780909 2 ORCLDB orcldb2 sun880-2
2080780909 3 ORCLDB orcldb3 sun880-3
Using 2080780909 for database Id
Using 1 for instance number
Specify 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 without
specifying a number lists all completed snapshots.
Enter value for num_days: 1
Listing the last day’s Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
———— ———— ——— —————— —–
orcldb1 ORCLDB 66 27 Jan 2008 00:55 1
67 27 Jan 2008 01:55 1
68 27 Jan 2008 02:55 1
69 27 Jan 2008 03:55 1
70 27 Jan 2008 04:55 1
71 27 Jan 2008 05:55 1
72 27 Jan 2008 06:55 1
73 27 Jan 2008 07:55 1
74 27 Jan 2008 08:55 1
75 27 Jan 2008 09:55 1
76 27 Jan 2008 10:55 1
77 27 Jan 2008 11:55 1
78 27 Jan 2008 12:55 1
83 27 Jan 2008 17:54 1
84 27 Jan 2008 18:55 1
85 27 Jan 2008 19:55 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 70
Begin Snapshot Id specified: 70
Enter value for end_snap: 71
End Snapshot Id specified: 71
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_70_71.txt. To use this name,
press to continue, otherwise enter an alternative.
Enter value for report_name:
Using the report name awrrpt_1_70_71.txt
WORKLOAD REPOSITORY report for
DB Name DB Id Instance Inst Num Release RAC Host
———— ———– ———— ——– ———– — ————
ORCLDB 2080780909 orcldb1 1 10.2.0.4.0 YES sun880-1
Snap Id Snap Time Sessions Curs/Sess
——— ——————- ——– ———
Begin Snap: 70 27-Jan-08 04:55:07 136 16.2
End Snap: 71 27-Jan-08 05:55:21 141 16.5
Elapsed: 60.23 (mins)
DB Time: 5,814.07 (mins)
Cache Sizes
~~~~~~~~~~~ Begin End
//此处有删减
————————————————————-
End of Report
Report written to awrrpt_1_70_71.txt
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Proction
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
[ractest@sun880-1 /u01/app/oracle/orahome/rdbms/admin]$ exit
script done on Sun 27 Jan 2008 08:48:16 PM PST
G. 大家帮看看ORACLE REPORT里的SQL语句问题
to_char(MO_LINES.MOL_MM_WIDTH,'0.9') MO_LINES.MOL_MM_WIDTH1,
to_char(MO_LINES.MOL_MM_LENGTH,'0.9') MO_LINES.MOL_MM_LENGTH1,
语法错了,别名不能这么写,MO_LINES 是table name,如果MO_LINES.MOL_MM_LENGTH1这样写会被解析成MO_LINES 的column,自然就报错,看看你的错误message就知道.
H. 在oracle report bulider开发中,pl/sql语句中出现了view该怎么办
给一个全能编译 无效数据库对象的脚本。
只要一运行什么都有了。。。
select decode(OBJECT_TYPE,
'PACKAGE BODY',
'alter package ' || OWNER || '.' || OBJECT_NAME ||
' compile body;',
'alter ' || OBJECT_TYPE || ' ' || OWNER || '.' || OBJECT_NAME ||
' compile;')
from dba_objects A
where STATUS = 'INVALID'
and OBJECT_TYPE in ('PACKAGE BODY', 'PACKAGE', 'FUNCTION', 'PROCEDURE',
'TRIGGER', 'VIEW')
order by OBJECT_TYPE, OBJECT_NAME;
I. oracle report6i怎样制作这样的报表
制表的时候有专门的格式化命令
TTITLE(顶标题) BTITLE(底标题) BREAK(设置断开点)
你说的效果可以通过BREAK实现 格式如下:
BREAKE ON 列名 SKIP N
列名你可以输入第一列的列名,N表示隔几行空一格
把BREAK 语句写在你的SELECT语句之前。
NO. Name sal
12 张三 45666
14 李四 3646
45 王五 31333
65 赵六 3133
56 刘思 323
不想要这样的效果的话,就删除断点。
CLEAR BREAK
J. 如何生成Oracle AWR报告
oracle手工生成AWR报告方法记录
AWR(Automatic Workload Repository)报告是DBA进行日常数据库性能评定、问题SQL发现的重要手段。熟练掌握AWR报告,是做好开发、运维DBA工作的重要基本功。
1、 运行脚本
首先,准备一个目录作为AWR生成报告的路径。
[oracle@bspdev /]$ ls -l | grep test
drwxr-xr-x. 2 oracle oinstall 4096 Jun 21 13:01 test
[oracle@bspdev /]$ cd test
启动sqlplus等开发工具,调用生成脚本。程序脚本一般保存在$ORACLE_HOME下的rdbms/admin中,名称为awrrpt.sql。
[oracle@bspdev test]$ sqlplus /nolog
SQL*Plus: Release11.2.0.1.0 Proction on Tue Jun 21 13:04:44 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected.
--调用脚本,生成文件
SQL> @?/rdbms/admin/awrrpt.sql
之后进入报告参数输入模块。
2、输入报告参数
之后,要持续输入一系列的报告参数。
ü 输入生成报告类型,目前AWR提供txt和html两种格式。需要确认生成格式,默认是html格式。
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
4143510747 ORA11G 1 ora11g
Specify 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'
ü 报告涉及天数范围
启动报告后,会显示生成实例的名称等基本信息。
默认情况下,AWR会将镜像信息保留一个月。手工生成的时候,需要确认生成AWR报告的时间范围。一般情况下,特别是生产环境下,我们通常设置1-7天也就够用了。
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 4143510747 1 ORA11G ora11g bspdev.local
domain
Using 4143510747 for database Id
Using 1 for instance number
Specify 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 without
specifying a number lists all completed snapshots.
Enter value for num_days:3
ü 输入开始和结束的snapshot编号
输入天数信息后,AWR生成代码会将天数范围内的snapshot镜像点列出,供输入选择。
Listing the last 3 days of Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
ora11g ORA11G 1789 20 Jun 2011 13:01 1
1790 20 Jun 2011 14:00 1
1791 20 Jun 2011 15:00 1
1792 20 Jun 2011 16:00 1
(篇幅原因,有省略……)
1811 21 Jun 2011 11:00 1
1812 21 Jun 2011 12:00 1
1813 21 Jun 2011 13:00 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
之后,我们需要根据列出的时间范围,输入开始和结束的snap编号。
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap:1796
Begin Snapshot Id specified: 1796
Enter value for end_snap:1813
ü 确定报告名称
最后就是确定生成报告的名称。一般采用默认的名称就可以了。
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_1796_1813.html. To use this name,
press to continue, otherwise enter an alternative.
Enter value for report_name:
之后输出内容很多,此处不加以累述。最后提示报告生成成功。
Report written to awrrpt_1_1796_1813.html
于是,指定目录上可以看到相应的报告文件。
[oracle@bspdev test]$ ls -l
total 508
-rw-r--r--. 1 oracle oinstall 515262 Jun 21 13:10 awrrpt_1_1796_1813.html