锘??xml version="1.0" encoding="utf-8" standalone="yes"?> ... 77 more 瑙e喅鍔炴硶錛?/p>
灝唎racle鐨刲ong瀛楁錛屼慨鏀規(guī)垚number綾誨瀷 java涓? double綾誨瀷 --------- oracle涓? number綾誨瀷 java涓? int綾誨瀷 --------- oracle涓? integer綾誨瀷
]]>
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
Caused by: java.sql.SQLException: 嫻佸凡琚叧闂?br />at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:226)
at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:165)
]]>
]]>濡備綍鐢⊿QL瀹炵幇絎涘崱灝?dāng)绉?nbsp;
闂紵錛?nbsp;
濡備綍鐢⊿QL瀹炵幇絎涘崱灝?dāng)绉?br />
澶ц櫨浠府甯繖 鎬?/span>!
鎬庝箞鍐欏憖?
絳旓紒錛?nbsp;1:
濂藉儚寰堢畝鍗?nbsp;浣嗗湪涓嬭彍鍟?/span>!
甯府蹇欏惂
絳旓紒錛?nbsp;2:
declare @t table(a int)
insert into @t select 1
insert into @t select 2
insert into @t select 3
declare @a table(b int)
insert into @a select 4
insert into @a select 5
insert into @a select 6
select * from @t,@a
select * from @t cross join @a
--2琛ㄧ殑絎涘崱灝?dāng)绉?nbsp;
絳旓紒錛?nbsp;3:
瑙i噴瑙i噴 姣忔悶榪囨暟鎹簱 鐪嬩笉鎳傚晩
絳旓紒錛?nbsp;4:
鐢╟ross join
鐩稿綋浜庝袱涓〃閲岀殑姣忎竴琛岄兘鐩鎬簰瀵瑰簲涓嬈°?nbsp;
絳旓紒錛?nbsp;5:
浣跨敤浜ゅ弶鑱旀帴
娌℃湁 WHERE 瀛愬彞鐨勪氦鍙夎仈鎺ュ皢浜х敓鑱旀帴鎵娑夊強(qiáng)鐨勮〃鐨勭瑳鍗″皵縐傜涓涓〃鐨勮鏁頒箻浠ョ浜屼釜琛ㄧ殑琛屾暟絳変簬絎涘崱灝?dāng)绉l撴灉闆嗙殑澶у皬銆備笅闈㈡槸 Transact-SQL 浜ゅ弶鑱旀帴紺轟緥錛?br />
USE pubs
SELECT au_fname, au_lname, pub_name
FROM authors CROSS JOIN publishers
ORDER BY au_lname DESC
--涓嬮潰鐨勬槸鍙︿竴縐嶅啓娉?br />
select * from @t,@a
絳旓紒錛?nbsp;6:
鍏堣阿璋㈠悇浣嶄簡
絳旓紒錛?nbsp;7:
Cross Join灝辨槸
絳旓紒錛?nbsp;8:
涓ゅ紶琛ㄧ殑瀛楁瀛楄妭鏌ヨ鑰屾病鏈夋煡璇㈡潯浠舵椂灝辨槸寰楀埌絎涘崱灝?dāng)闆?br />
濡傦細(xì)select A.a1,B.b1 from A,B
寰楀埌鐨勫氨鏄痑1瀛楁涓巃2瀛楁鐨勭瑳鍗″皵闆?nbsp;
絳旓紒錛?nbsp;9:
use pubs
go
select * from titles, authors
絳旓紒錛?nbsp;10:
鍒啓where鏉′歡,鑷姩浼?xì)鎴愪皋Z綘瑕佹眰鐨勯偅鏍風(fēng)殑!
]]>
寤鴻〃錛?br />dept:
聽deptno(primary key),dname,loc
emp:
聽empno(primary key),ename,job,mgr,sal,deptno
*/
1 鍒楀嚭emp琛ㄤ腑鍚勯儴闂ㄧ殑閮ㄩ棬鍙鳳紝鏈楂樺伐璧勶紝鏈浣庡伐璧?br />select max(sal) as 鏈楂樺伐璧?min(sal) as 鏈浣庡伐璧?deptno from emp group by deptno;
2 鍒楀嚭emp琛ㄤ腑鍚勯儴闂╦ob涓?CLERK'鐨勫憳宸ョ殑鏈浣庡伐璧勶紝鏈楂樺伐璧?br />select max(sal) as 鏈楂樺伐璧?min(sal) as 鏈浣庡伐璧?deptno as 閮ㄩ棬鍙?from emp where job = 'CLERK' group by deptno;
3 瀵逛簬emp涓渶浣庡伐璧勫皬浜?000鐨勯儴闂紝鍒楀嚭job涓?CLERK'鐨勫憳宸ョ殑閮ㄩ棬鍙鳳紝鏈浣庡伐璧勶紝鏈楂樺伐璧?br />select max(sal) as 鏈楂樺伐璧?min(sal) as 鏈浣庡伐璧?deptno as 閮ㄩ棬鍙?from emp as b
where job='CLERK' and 1000>(select min(sal) from emp as a where a.deptno=b.deptno) group by b.deptno
4 鏍規(guī)嵁閮ㄩ棬鍙風(fēng)敱楂樿屼綆錛屽伐璧勬湁浣庤岄珮鍒楀嚭姣忎釜鍛樺伐鐨勫鍚嶏紝閮ㄩ棬鍙鳳紝宸ヨ祫
select deptno as 閮ㄩ棬鍙?ename as 濮撳悕,sal as 宸ヨ祫 from emp order by deptno desc,sal asc
5 鍐欏嚭瀵逛笂棰樼殑鍙︿竴瑙e喅鏂規(guī)硶
錛堣琛ュ厖錛?/p>
6 鍒楀嚭'寮犱笁'鎵鍦ㄩ儴闂ㄤ腑姣忎釜鍛樺伐鐨勫鍚嶄笌閮ㄩ棬鍙?br />select ename,deptno from emp where deptno = (select deptno from emp where ename = '寮犱笁')
7 鍒楀嚭姣忎釜鍛樺伐鐨勫鍚嶏紝宸ヤ綔錛岄儴闂ㄥ彿錛岄儴闂ㄥ悕
select ename,job,emp.deptno,dept.dname from emp,dept where emp.deptno=dept.deptno
8 鍒楀嚭emp涓伐浣滀負(fù)'CLERK'鐨勫憳宸ョ殑濮撳悕錛屽伐浣滐紝閮ㄩ棬鍙鳳紝閮ㄩ棬鍚?br />select ename,job,dept.deptno,dname from emp,dept where dept.deptno=emp.deptno and job='CLERK'
9 瀵逛簬emp涓湁綆$悊鑰呯殑鍛樺伐錛屽垪鍑哄鍚嶏紝綆$悊鑰呭鍚嶏紙綆$悊鑰呭閿負(fù)mgr錛?br />select a.ename as 濮撳悕,b.ename as 綆$悊鑰?from emp as a,emp as b where a.mgr is not null and a.mgr=b.empno
10 瀵逛簬dept琛ㄤ腑錛屽垪鍑烘墍鏈夐儴闂ㄥ悕錛岄儴闂ㄥ彿錛屽悓鏃跺垪鍑哄悇閮ㄩ棬宸ヤ綔涓?CLERK'鐨勫憳宸ュ悕涓庡伐浣?br />select dname as 閮ㄩ棬鍚?dept.deptno as 閮ㄩ棬鍙?ename as 鍛樺伐鍚?job as 宸ヤ綔 from dept,emp
where dept.deptno *= emp.deptno and job = 'CLERK'
11 瀵逛簬宸ヨ祫楂樹簬鏈儴闂ㄥ鉤鍧囨按騫崇殑鍛樺伐錛屽垪鍑洪儴闂ㄥ彿錛屽鍚嶏紝宸ヨ祫錛屾寜閮ㄩ棬鍙鋒帓搴?br />select a.deptno as 閮ㄩ棬鍙?a.ename as 濮撳悕,a.sal as 宸ヨ祫 from emp as a
where a.sal>(select avg(sal) from emp as b where a.deptno=b.deptno) order by a.deptno
12 瀵逛簬emp錛屽垪鍑哄悇涓儴闂ㄤ腑騫沖潎宸ヨ祫楂樹簬鏈儴闂ㄥ鉤鍧囨按騫崇殑鍛樺伐鏁板拰閮ㄩ棬鍙鳳紝鎸夐儴闂ㄥ彿鎺掑簭
select count(a.sal) as 鍛樺伐鏁?a.deptno as 閮ㄩ棬鍙?from emp as a
where a.sal>(select avg(sal) from emp as b where a.deptno=b.deptno) group by a.deptno order by a.deptno
13 瀵逛簬emp涓伐璧勯珮浜庢湰閮ㄩ棬騫沖潎姘村鉤錛屼漢鏁板涓?浜虹殑錛屽垪鍑洪儴闂ㄥ彿錛屼漢鏁幫紝鎸夐儴闂ㄥ彿鎺掑簭
select count(a.empno) as 鍛樺伐鏁?a.deptno as 閮ㄩ棬鍙?avg(sal) as 騫沖潎宸ヨ祫 from emp as a
where (select count(c.empno) from emp as c where c.deptno=a.deptno and c.sal>(select avg(sal) from emp as b where c.deptno=b.deptno))>1
group by a.deptno order by a.deptno
14 瀵逛簬emp涓綆浜庤嚜宸卞伐璧勮嚦灝?浜虹殑鍛樺伐錛屽垪鍑哄叾閮ㄩ棬鍙鳳紝濮撳悕錛屽伐璧勶紝浠ュ強(qiáng)宸ヨ祫灝戜簬鑷繁鐨勪漢鏁?br />select a.deptno,a.ename,a.sal,(select count(b.ename) from emp as b where b.sal<a.sal) as 浜烘暟 from emp as a
where (select count(b.ename) from emp as b where b.sal<a.sal)>5