2007年10月15日星期一
远程重新启动服务器
本来想找系统管理员到机器旁边去看一下,不过看到是自己犯的错误,还是自己先想办法吧。网络真好,通过如下两个命令搞定了:
net use \\192.168.0.3\admin$ adminpasswd /user:administrator
shutdown -r -m \\192.168.0.3 -t 30 -f
2007年10月10日星期三
几个itpub关于采购审批层次的帖子
在po中定义了审批层次,我想问一下,在采购订单提交审批的时候,按照什么样的规则提交给不同层次的审批者?比如:一级a,二级b,三级c,b有5000元的最高审批权限,那么c做的采购订单什么情况下会由a来审批呢?超出5000元么?是由b转给a ,还是直接发送到了a????
A: 没有试验,不知道如下是否满足你的需求
1)首先需要设定两个审批组一个审判GroupB审批的金额1~5000,另外一个组Group审批金额为5001~99999999999999999。
2)审批组分配。将b的职位分配到GroupB,将a的职位分配到GroupA。
3)设置文档类型的Foward Method的属性。如果超过5000,直接到A,那么将Forward Method属性值设为Direct。如果需要B转交,那么将Forward Method属性值设为Hiberarchy
URL:http://www.itpub.net/649786.html
Q: 怎样指定审批层次的默认审批人
因为公司同时使用了HR和PO模块。在HR模块中处于同一个position(PA)的有多个人(MA,MB,MC等),这个position在采购的审批层次中,而这个position的几个人中,只有一个(MB)负责采购审批业务。 问题在于:用户提交单据的时候,发现审批路径上的人默认的时MA,而不是MB,这个用户带来很大的困惑。 请问是否有什么可以预制文件或者设置的地方,将MB设定为默认的审批人呢?
A:OSS给出回复:
1) 如果是11.5.9版本,没有这个功能,以字母的ascii码顺序默认审批人。
参考Metalink:Note 106596.1
Another method that must be considered is one where the application choosesthe forward-to person when multiple employees are tied to one position. Theapplication will select the forward-to person based on alphabetical nameorder. Here is an example to better clarify how the system chooses the nextapprover name when multiple approvers are assigned to one position:Position: ClerkEmployees Assigned: ManyReports To: Vice President, MaterialsPostion: Vice President, MaterialsEmployees Assigned: Dough, John S.Smith, Bob A.In this example, if a clerk chooses the Approve button without entering aforward-to person, and the next position above the clerk is theVice President of Materials, the document would be routed to John Dough.John Dough is selected because the system will choose the employee assignedto the position in alphabetical order, and since Dough comes before Smith,John Dough is selected. Therefore, unless the clerk selects a specificperson to forward the document to, the document will always be routed to thefirst person alphabetically assigned to the position.
2) 如果是11.5.10版本,安装Oracle Approvals Management (AME) ,可以设定默认审批人。
参考Metalink:Note 229663.1
Oracle Approvals Management (AME) is a web–based application which is integrated with Oracle Workflow and which enables you to define business rules to control your approvals processes. With AME, you use the following components to define your approvals processes. They are associated with a transaction type for a particular application.• Attribute – this is a business variable, for example, a salary amount, user ID, or workflow process name.• Condition – a condition compares an attribute value with a set of allowed attribute values. For example, a condition could look at a salary amount. If the salary is greater than a specified value, a particular approver list is created.• Approval type and approval specifications – these components define the type of approver list that is generated. For example, to generate a supervisor–based approver list with 5 levels, you use the ’supervisory level’ approval type with the ’requires approval up to the first 5 approvers’ approval specification.• Rules – a rule links the other components together by associating one or more conditions with the approval type and approval rule
http://www.itpub.net/616596,2.html
2007年9月2日星期日
访问form界面,IE窗口退出
An unexpected exception has been detected in native code outside the VM.Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x77ea364eFunction name=NdrRpcSsDefaultAllocateLibrary=C:\WINDOWS\system32\RPCRT4.dll
通过google查询,发现部分关于vista中怎样使用Jinitiator是用高版本的jvm替换对应的jvm。发现并不能解决问题,卸载掉部分jre的版本也没能够解决问题。最后还是在metalink上找到了解决方法,是msn的插件的问题,想起来前两天还错点了msn的按钮,应该是这个原因吧:
Solution
-- To implement the solution, please execute the following steps::Suggest to check if this plug in is installed and enabled. If this is the case disable it using the following actions:1.Tools - Manage Add-ons - Enable or Disable Add-ons
2. In Show option - "Add-ons that have been used by Internet Explorer"Select from the list and check for Name "Windows Live ...."
e.g "Windows Live Messenger", "Windows Live Sing-in Helper" etc.
3. Select "Disable" option4. Close all the Internet explorer browser sessions. Restart the client machine.
5. Retest the issue.
参考:Note:435562.1
2007年8月25日星期六
2000 servers终于可以通过网络访问了
1、是否添加了“文件和打印共享”
2、组策略中是否禁止了你用来访问的用户?
发现都不是这些问题所在。无意在组策略的安全设置中,发现“IP安全策略,在本地机器中-〉安全服务器”是选中的,将其去掉就OK。
现在终于可以从其他两台机器来访问这台服务器了。
2007年8月17日星期五
数据库导入导出乱码问题
项目数据需要清理,DBA将数据按照用户导出发过了。导入数据的时候,发现数据库中文全部变成问号。上网找了一下资料,发现原来是数据库字符集不兼容。导入数据库的字符集WE8ISO8859P9,而导出数据库的字符集为ZHS16GBK。
第一个想法就是更改导入数据库的字符集,通过如下语句:ALTER DATABASE CHARACTER SET ZHS16GBK进行更改,系统提示“ORA-12712 new character set must be a superset of old character set”。原来使用这个语句还需要考虑更改的字符集与原来数据库的字符集兼容。Metalink Note:119164.1上定义了不同字符集的兼容关系。
只有重新建立一个库,设定字符集为ZHS16GBK/AL16UTF16。Imp的时候,系统显示的日志为:
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
export client uses ZHS16CGB231280 character set (possible charset conversion)
export server uses ZHS16GBK NCHAR character set (possible ncharset conversion)
可以看到DBA导出的时候客户端字符集为“ZHS16CGB231280”,导出的数据库字符集为“ZHS16GBK”,这两个字符集也不完全兼容,以后导出的时候需要注意更改客户端字符集。导入的数据库的字符集为“ZHS16GBK”。导入完成之后,没有发现乱码问题。
总结:
1. 导入导出过程中涉及4个字符集,需要保证字符集的兼容性,才可能避免汉字乱码问题。
源数据库字符集
Export过程中用户会话字符集(通过NLS_LANG设定)
Import过程中用户会话字符集(通过NLS_LANG设定)
目标数据库字符集
2. 字符集兼容可以通过Metalink Note:119164.1查询。
3. 同时,在安装数据库的时候,应该根据业务需求选定好字符集,而不是采用安装过程的默认设置。
参考:
网上非常好的一篇文章:http://silverw0396.javaeye.com/blog/90554
2007年8月14日星期二
Trace Discoverer Workbook
修改注册表的值
\\HKEY_CURRENT_USER\Software\Oracle\Discoverer\Database\SqlTrace
type DWORD
numeric value 1
使用这个的前提是需要trace的工作簿查询尚未运行。如果已经运行了,可以通过方法2来完成。
另,完成trace之后,别忘记更改回去。
通过SQL
a. 通过如下SQL定位discoverer的session以及spid。从而可以对对应的session进行跟踪。从而可以通过spid知道trace文件的名称。
SELECT s.SID, s.serial#, s.username, s.program, p.spid
FROM v$session s, v$process p
WHERE p.addr = s.paddr
AND s.program LIKE '%DIS4USR.EXE%'
得到
SID:72 serial#49228 SPID:5865
SID:132 serial#56294 SPID:5877
b. ENABLE TRACE
exec dbms_system.set_sql_trace_in_session(72, 49228, TRUE)
exec dbms_system.set_sql_trace_in_session(132, 56294, TRUE)
c. 执行discoverer相关操作,例如运行工作簿,共享工作簿等。
d. 从文件菜单中推出discoverer,这一步比较重要,如果是进行性能分析话,保证执行计划相关资源数据的完整性。
e. Disable trace.
f. 通过步骤a得到的spid,从数据库下载对应的trace文件。格式化trace文件,判断哪一个是需要的trace文件,对正确的trace文件进行分析。
tkprof onidau1_ora_5865.trc 14_2_1.txt sys = no;
tkprof onidau1_ora_5877.trc 14_2_2.txt sys=no;
参考:metalink. Note:273928.1
2007年8月10日星期五
《Expert one on one Oracle》- 物化视图 - 笔记
一个例子
通过如下的例子,对比统计数据需求的情况下,使用物化视图会有更快的访问速度。
--创建一张大表
SQL> create table my_all_objects
2 nologging
3 as
4 select * from all_objects
5 union all
6 select * from all_objects
7 union all
8 select * from all_objects
9 /
Table created.
SQL> insert /*+ APPEND */ into my_all_objects
2 select * from my_all_objects;
87945 rows created.
SQL> commit;
Commit complete.
SQL> insert /*+ APPEND */ into my_all_objects
2 select * from my_all_objects;
175890 rows created.
SQL> commit;
Commit complete.
SQL> analyze table my_all_objects compute statistics;
Table analyzed.
SQL> set autotrace traceonly
--通过执行计划可以得知直接对数据进行count计算,需要访问4800数据块
SQL> select owner, count(*) from my_all_objects group by owner;
28 rows selected.
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=989 Card=28 Bytes=14
0)
1 0 SORT (GROUP BY) (Cost=989 Card=28 Bytes=140)
2 1 TABLE ACCESS (FULL) OF 'MY_ALL_OBJECTS' (Cost=471 Card=3
51780 Bytes=1758900)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
4804 consistent gets
3004 physical reads
0 redo size
973 bytes sent via SQL*Net to client
510 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
28 rows processed
SQL> set autotrace off
--赋予测试用户query rewrite的权限
SQL> grant query rewrite to scott;
Grant succeeded.
--更改当前session能够query rewrite
SQL> alter session set query_rewrite_enabled=true;
Session altered.
--设定query_rewrite_integrity的值为enforced,有三个置可选,enforced,trusted,STALE_TOLERATED
SQL> alter session set query_rewrite_integrity=enforced;
Session altered.
--创建物化视图
SQL> create materialized view my_all_objects_aggs
2 build immediate
3 refresh on commit
4 enable query rewrite
5 as
6 select owner, count(*)
7 from my_all_objects
8 group by owner
9 /
Materialized view created.
--分析物化视图
SQL> analyze table my_all_objects_aggs compute statistics;
Table analyzed.
--通过执行计划可以得知再进行同样的count计算,只需要访问5个数据块。同时,通过执行路径也可以看到,查询是通过物化视图来完成的。如果业务上对于这种count的计算比较频繁的话,采用物化视图将会节省更多的资源。是一种以空间换取时间的方法。
SQL> set autotrace traceonly
SQL> select owner, count(*)
2 from my_all_objects
3 group by owner;
28 rows selected.
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=28 Bytes=252)
1 0 TABLE ACCESS (FULL) OF 'MY_ALL_OBJECTS_AGGS' (Cost=2 Card= 28 Bytes=252)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
5 consistent gets
0 physical reads
0 redo size
973 bytes sent via SQL*Net to client
510 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
28 rows processed
SQL> set autotrace off
--插入新的纪录
SQL> insert into my_all_objects
2 ( owner, object_name, object_type, object_id )
3 values
4 ( 'New Owner', 'New Name', 'New Type', 1111111 );
1 row created.
SQL> commit;
Commit complete.
SQL> set timing on
--对新纪录的count计算仍然通过物化视图来访问。由于创建物化视图的时候,使用“refresh on commit”语句,表的新增纪录已经刷新到物化视图。
SQL> select owner, count(*)
2 from my_all_objects
3 where owner = 'New Owner'
4 group by owner;
OWNER COUNT(*)
------------------------------ ----------
New Owner 1
Elapsed: 00:00:00.00
SQL> set timing off
SQL>
SQL> set autotrace traceonly
SQL> select owner, count(*)
2 from my_all_objects
3 where owner = 'New Owner'
4 group by owner;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=9)
1 0 TABLE ACCESS (FULL) OF 'MY_ALL_OBJECTS_AGGS' (Cost=2 Card= 1 Bytes=9)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
4 consistent gets
0 physical reads
0 redo size
442 bytes sent via SQL*Net to client
499 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> set autotrace off
--更改sql,不查询owner字段,只count,发现Oracle足够聪明,即使没有创建物化视图的group语句,还是从物化视图来访问
SQL> set autotrace traceonly
SQL> select count(*)
2 from my_all_objects
3 where owner = 'New Owner';
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=9)
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'MY_ALL_OBJECTS_AGGS' (Cost=2 Card=1 Bytes=9)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
3 consistent gets
0 physical reads
0 redo size
379 bytes sent via SQL*Net to client
499 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> set autotrace off
对于事物频繁的OLTP系统,尽量少使用物化视图。
设置参数
如下参数可以在数据库层或者Session层设置QUERY_REWRITE_ENABLED和
QUERY_REWRITE_INTEGRITY值。对于QUERY_REWRITE_INTEGRITY有三种值可设:
Enforced:重写只使用数据库中定义的约束和关系。
Trusted:除了数据库中定义的约束和关系,Oracle还会使用其他我们告知Oracle表的某些关系,从而使得数据库能够重写更多的查询。
Stale_Tolerated:最弱的参数,及时物化视图没有同步更新,也会使用物化视图来重写SQL。
查询重写
全文精确匹配
如果查询的语句与存储在数据词典中物化视图字符串精确匹配,那么将会重写查询。这里的精确匹配相对于共享池的比较而言更友好,它会忽略空格,大小写以及其他的一些格式。
部分文本匹配
比较From因子后面的文本,即使Select部分的不匹配。例如:
接前面的例子,物化视图的查询部分的SQL:
Select owner, count(*) from my_all_objects group by owner
如下的查询能够被重写:
Select lower(owner) from my_all_objects group by owner
一般性重写方法
a. 数据满足:查询的数据列在物化视图的查询列中
b. 连接兼容:查询语句中的关联列需要在物化视图的查询列中
c. 分组兼容:查询语句和物化视图都必须有Group by语句,同时物化视图的Group by分组层次应该高于或者等于查询的语句。
d. 聚集兼容:查询语句和物化视图都必须包含聚集语句。如果物化视图包含SUM ()/COUNT () 函数,对于同样列采用AGE () 函数进行计算可以被重写。
确保使用物化视图
如下的例子将会说明在怎样的条件下可以确保采用物化视图重写查询,也会比较QUERY_REWRITE_INTEGRITY值Enforced和Trusted的不同。
--这一部分语句验证如果在数据库中相关约束,而这种约束在定义物化视图
--使用。那么,如果查询即使满足其它被重写的条件(数据满足,关联兼容,
--分组兼容等),也不会被重写。
--创建测试表和物化视图
SQL> create table emp as select * from scott.emp;
Table created.
SQL> create table dept as select * from scott.dept;
Table created.
SQL> alter session set query_rewrite_enabled=true;
Session altered.
--注意这里使用的参数值为enforced,只有查询中的约束和关系在物化视图中存在,才会重写查询。
SQL> alter session set query_rewrite_integrity=enforced;
Session altered.
--创建物化视图,注意这里是“refresh on demand”,需要手动刷新物化视图
SQL> create materialized view emp_dept
2 build immediate
3 refresh on demand
4 enable query rewrite
5 as
6 select dept.deptno, dept.dname, count (*)
7 from emp, dept
8 where emp.deptno = dept.deptno
9 group by dept.deptno, dept.dname
10 /
Materialized view created.
SQL> alter session set optimizer_goal=all_rows;
Session altered.
SQL> set autotrace on
--通过执行计划可以看到这个查询并没有被重写,而是直接访问表“EMP”。这是因为我们并没有定义表emp和dept的之间的主外健之间的关系,这种关系物化视图中使用,例如“emp.deptno = dept.deptno”
SQL> select count(*) from emp;
COUNT(*)
----------
14
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=1)
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'EMP' (Cost=2 Card=82)
Statistics
----------------------------------------------------------
….略
--这一部分语句验证增加相关约束后,查询被重写。
--增加相关的约束和关系
SQL> alter table dept
2 add constraint dept_pk primary key(deptno);
Table altered.
SQL> alter table emp
2 add constraint emp_fk_dept
3 foreign key(deptno) references dept(deptno);
Table altered.
SQL> alter table emp modify deptno not null;
Table altered.
SQL> set autotrace on
--由于增加了约束,Oracle能够重写查询使其通过物化视图“EMP_DEPT”来访问数据。可以查看下面的highlight部分的执行计划。
SQL> select count(*) from emp;
COUNT(*)
----------
14
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=1 Bytes=13)
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'EMP_DEPT' (Cost=2 Card=82 Bytes=
1066)
Statistics
----------------------------------------------------------
略….
SQL> set autotrace off
--下面这部分SQL将会在比较query_rewrite_integrity在取值为Enforced和
--Trusted情况下,是否被重写。
--删除上述步骤建立的约束
SQL> alter table emp drop constraint emp_fk_dept;
Table altered.
SQL> alter table dept drop constraint dept_pk;
Table altered.
SQL> alter table emp modify deptno null;
Table altered.
--插入数据
SQL> insert into emp (empno,deptno) values ( 1, 1 );
1 row created.
--手工刷新物化视图,这是因为物化视图创建的时候使用的是“refresh on demand”
SQL> exec dbms_mview.refresh( 'EMP_DEPT' );
PL/SQL procedure successfully completed.
--再次增加约束,但是这次增加了NOVALIDATE因子。这样即使数据不符合约束也能够成功创建。
SQL> alter table dept
2 add constraint dept_pk primary key(deptno)
3 rely enable NOVALIDATE
4 /
Table altered.
SQL> alter table emp
2 add constraint emp_fk_dept
3 foreign key(deptno) references dept(deptno)
4 rely enable NOVALIDATE
5 /
Table altered.
SQL> alter table emp modify deptno not null NOVALIDATE;
Table altered.
SQL> set autotrace on
--设置query_rewrite_integrity值为enforced
SQL> alter session set query_rewrite_integrity=enforced;
Session altered.
--检查增加约束但数据不满足约束的情况下,如果是query_rewrite_integrity的值为enforcedenforced,那么物化视图不会被利用来重写查询。
SQL> select count(*) from emp;
COUNT(*)
----------
15
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=1)
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'EMP' (Cost=2 Card=164)
Statistics
----------------------------------------------------------
略….
--设置query_rewrite_integrity值为trusted
SQL> alter session set query_rewrite_integrity=trusted;
Session altered.
--检查增加约束但数据不满足约束的情况下,如果是query_rewrite_integrity的值为trusted,那么物化视图将会被利用来重写查询。
SQL> select count(*) from emp;
COUNT(*)
----------
14
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=1 Bytes=13)
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'EMP_DEPT' (Cost=2 Card=82 Bytes=
1066)
Statistics
----------------------------------------------------------
略….
Dimension
创建纬度映射不同列之间的父子关系,类似于在discoverer中创建的维度,使得在查询的时候根据需求下钻上卷。在这里可以为Oracle提供更多的信息,从而使得重写查询的可能性增大。非常类似discoverer中的hierarchy的概念。
create dimension sales_dimension
--这一部分定义类似于数据库字段的别名
level cust_id is customer_hierarchy.cust_id
level zip_code is customer_hierarchy.zip_code
level region is customer_hierarchy.region
level day is time_hierarchy.day
level mmyyyy is time_hierarchy.mmyyyy
level qtr_yyyy is time_hierarchy.qtr_yyyy
level yyyy is time_hierarchy.yyyy
--定义其中一个层次结构
hierarchy cust_rollup
(
cust_id child of
zip_code child of
region
)
--定义另外一个层次结构
hierarchy time_rollup
(
day child of
mmyyyy child of
qtr_yyyy child of
yyyy
)
--mmyyyy和mon_yyyy是同义词
attribute mmyyyy
determines mon_yyyy;
DBMS_OLAP
通过DBMS_OLAP,可以完成如下工作:
a. 估算物化视图的大小
b. 验证维度对象是否有效
c. 建议建立起它物化视图,找出需要删除的视图并重命名
d. 评估物化视图的使用状况
