易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL语句PART10

oracle tips
Exist的用法:
select gw.ndocid from 
(select ndocid from wf_doc_gw_shouwen union select ndocid from wf_doc_gw_fawen) gw
where
not exists (select null from wf_doc_gw_sn sn where sn.ndocid=gw.ndocid)
2。把GW表和SN表里相同的NDOCID显示出来
select gw.ndocid from 
(select ndocid from wf_doc_gw_shouwen union select ndocid from wf_doc_gw_fawen) gw
where
exists (select null from wf_doc_gw_sn sn where sn.ndocid=gw.ndocid)
  
DECODE的语法:DECODE(value,if1,then1,if2,then2,if3,then3,...,else),
e.g.:
select decode(max(documentid), null, 1, (max(documentid)+1))) from document;  
results:
if null, display 1
else    display max(documentid)+1
1. export database
cmd
%oracle_home%\bin\exp carmot/carmot@132.159.178.236_igrp2 file=d:\a.dmp
2. oracle enterprise console
connect as sysdba
安全性,右键,建立用户carmot_hunan_1,密码用carmot
给dba权限。
3. import database
cmd
%oracle_home%\bin\imp carmot_hunan_1/carmot@132.159.178.236_igrp2 file=d:\a.dmp fromuser=carmot
** remarks:
carmot_hunan_1/carmot@132.159.178.236_igrp2
用户名/密码@配置在TOAD中的数据库名称
例如: TOAD中数据库的名称是:  IGRP2_132.159.178.236, 则为: carmot_hunan_1/carmot@igrp2_132.159.178.236
Example for complicated select:
 
select distinct first_value(ndocid) over (partition by ndocid order by lv desc) as ndocid,
--first_value(curtitle) over (partition by ndocid order by lv desc) as
curtitle,
first_value(realname) over (partition by ndocid order by lv desc) as realname
from(
select ndocid,curtitle, sys_connect_by_path(realname,' ') realname, level lv from
(select ndocid, curtitle,realname, lag(realname,1,null) over (partition by ndocid order by realname) realname_1
from (select g.ndocid,g.curtitle, u.realname
from wf_doc_gw g, tbuser u
where instr(','||g.cprocuserlist||',',','||u.userid||',')>0)) connect by prior realname=realname_1) order by ndocid
e.g.:
select g.ndocid, g.cproc


相关文档:

[转]SQL行列互换

问题:假设有张学生成绩表(tb)如下:
姓名 课程 分数
张三 语文 74
张三 数学 83
张三 物理 93
李四 语文 74
李四 数学 84
李四 物理 94
想变成(得到如下结果): 
姓名 语文 数学 物理 
---- ---- --- ......

SQL SERVER 2005 .NET UDF

using System;
using System.Text.RegularExpressions;
using Microsoft.SqlServer.Server;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction(IsDeterministic = true,IsPrecise = true)]
public static bool RegExIsMatch(string pattern,string matchString)
{ ......

ORACLE和POSTGRESQL的SQL语句比较

oracle 方法                                                & ......

SQL语句PART4

GRANT
Name
GRANT -- 定义访问权限
Synopsis GRANT { { SELECT | INSERT | UPDATE | DELETE | RULE | REFERENCES | TRIGGER }
    [,...] | ALL [ PRIVILEGES ] }
    ON [ TABLE ] tablename [, ...]
    TO { username | GROUP groupname | PUBLIC } [, ...] [ WI ......

SQL语句PART6

Differring Constraints:
Constraints can have the following attributes: DEFFERRABLE / NOT DEFFERRABLE,  INITIALLY DEFFERRED / INITIALLY IMMEDIATE.
e.g.:
alter table dept2 add constraint dept2_id_pk primary key (department_id) deferrable initially deferred; // deferring constraint on creation. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号