Oracle SQL实例
1。select * from a where a.rowid=(select min(b.rowid) from b where a.id=b.id);
create test1(
nflowid number primary key,
ndocid number,
drecvdate date);
insert into test1 values (1, 12301, sysdate) ;
insert into test1 values (2, 12301, sysdate);
select * from test1 order by drecvdate:
result:
nflowid ndocid drecvdate
1 12301 2010-2-1
2 12301 2010-2-2
要求: 根据NDOCID为查询条件, DRECVDATE排序,显示重复数据中最小的那条记录
String sql1 = "select * from test1 where ndocid=12301 order by decvdate";
String sql2 = "select * from (" + sql1 + ") a where a.rowid=" +
"(select min(b.rowid) from (" + sql1 + ") b " +
"where a.ndocid=b.ndocid)";
要点: 1. nflowid 是PK, 如果不是PK, 则有可能会报告ORA-1445 错误
2. 此语句,不管NFLOWID=1的DRECVDAGTE比NFLOWID=2的DRECVDATE早还是晚,都返回:
1, 12301 2010-2-1. 原因我觉得:这个ROWID貌似就是NFLOWID的值
String agentSql = "select u.*, e.ndeputyentityid, e.nentityid " +
"from tbuser u, tbuser_role ur, doc_dept_deputy e " +
"where u.userid = ur.userid " +
"and u.currententityid = e.ndeputyentityid " +
"and ur.roleid=" + roleId;
String aSql = "select * from(" + agentSql + ") a where " +
"a.userpriority=(select min(b.userpriority) from(" + agentSql + ") b " +
"where a.ndeputyentityid = b.ndeputyentityid) " +
"and a.userid=(select min(b.userid) from(" + agentSql + ") b " +
"where a.ndeputyentityid = b.ndeputyentityid and a.userpriority = b.userpriority)";
要点:
1) 如果userpriority没有重复值,则结果返回userpriority最小值的记录
2) 如果userpriority有重复值,则结果返回userid最小值的记录
相关文档:
系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......
方案一:
新装了系统后,发现在调试程序时TOMCAT提示8080端口已被占用,于是运行NETSTAT -ANO查看端口使用情况,发现8080端口被ORACLE的监听器给占用了,于是结合上网查到方法,将ORACLE XDB的HTTP服务端口改成8081,问题解决。
总结一下可解决的方 ......
首先搞清下几个概念:
ORACLE中,约束分deferred 跟 immediate 2种:
deferred:如果 Oracle 在事务提交(commit)时才对约束执行检查,则称此约束是延迟的(deferred)。如果数据违反了延迟约束,提交操作将导致事务被回滚(undo)。
immediate:如果约束是即时的(immediate)(非延迟的),则此约束将在 ......
我用的是Centos5.4 DVD光盘安装的linux操作系统,安装linux的时候选上开发工具,Xmanager,与数据库相关的包。
操作系统安装完成之后需要进行一系列的配置才能安装oracle10g,下面把主要步骤记录下来。
1.安装完操作系统之后还是有些包没有安装,然而安装oracle10g的时候需要用到,没有安装的包有:
libXp-1.0.0-8.i386.rp ......