SQLÓï¾ä¸´ÖƱíµÄ·½·¨
SQLÓï¾ä¸´ÖƱíµÄ·½·¨
(2009-08-29 13:41:54)
±êÇ©£º
sql
·ÖÀࣺ¼ÆËã»ú֪ʶ
Èç¹ûÄ¿µÄ±íÒѾ´æÔÚ:
insert into DATAHR.DBO.GBITEM
select * from DEMO.DBO.GBITEM
Èç¹ûÄ¿µÄ±í²»´æÔÚ:
select * into DATAHR.DBO.GBITEM
from DEMO.DBO.GBITEM
¿ç¿âµ¼Èë
select * into [zk_news].[dbo].[News1] from [zk_media].[dbo].[News]
--±¸·ÝÊý¾Ý¿âOFSys
BACKUP DATABASE OFSys to disk = 'e:/OFSys'
»¹Ô
restore database test from disk = 'c:\test'
¾«ÃîSQLÓï¾ä
¾«ÃîSQLÓï¾ä
˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb)
SQL: select * into b from a where 1<>1
˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d,e,f from b;
˵Ã÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä
SQL: select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
˵Ã÷£ºÍâÁ¬½Ó²éѯ(±íÃû1£ºa ±íÃû2£ºb)
SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
˵Ã÷£ºÈճ̰²ÅÅÌáÇ°Îå·ÖÖÓÌáÐÑ
SQL: select * from Èճ̰²ÅÅ where datediff('minute',f¿ªÊ¼Ê±¼ä,getdate())>5
˵Ã÷£ºÁ½ÕŹØÁª±í£¬É¾³ýÖ÷±íÖÐÒѾÔÚ¸±±íÖÐûÓеÄÐÅÏ¢
SQL:
delete from info where not exists ( select * from infobz where info.infid=infobz.infid )
˵Ã÷£º--
SQL:
SELECT A.NUM, A.NAME, B.UPD_DATE, B.PREV_UPD_DATE
from TABLE1,
(SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE
from (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND
from TABLE2
WHERE TO_CHAR(UPD_DATE,'YYYY/MM') = TO_CHAR(SYSDATE, 'YYYY/MM')) X,
(SELECT NUM, UPD_DATE, STOCK_ONHAND
from TABLE2
WHERE TO_CHAR(UPD_DATE,'YYYY/MM') =
TO_CHAR(TO_DATE(TO_CHAR(SYSDATE, 'YYYY/MM') || '/01','YYYY/MM/DD') - 1, 'YYYY/MM') ) Y,
WHERE X.NUM = Y.NUM £¨+£©
AND X.INBOUND_QTY + NVL(Y.STOCK_ONHAND,0) <> X.STOCK_ONHAND ) B
WHERE A.NUM = B.NUM
˵Ã÷£º--
SQL:
select * from studentinfo where not exists(select * from student where studentinfo.id=student.id) and ϵÃû³Æ='"&strdepartmentname&"' and רҵÃû³Æ='"&strprofessionname&"' order by ÐÔ±ð,ÉúÔ´µØ,¸ß¿¼×ܳɼ¨
˵Ã÷£º
Ïà¹ØÎĵµ£º
/*
½¨±í£º
dept:
deptno(primary key),dname,loc
emp:
empno(primary key),ename,job,mgr,sal,deptno
*/
1 Áгöemp±íÖи÷²¿ÃŵIJ¿Ãźţ¬×î¸ß¹¤×Ê£¬×îµÍ¹¤×Ê
select max(sal) as ×î¸ß¹¤×Ê,min(sal) as ×îµÍ¹¤×Ê,deptno from emp group by deptno;
2 Áгöemp±íÖи÷²¿ÃÅjobΪ'CLERK'µÄÔ±¹¤µÄ×îµÍ¹¤×Ê£¬×î¸ß¹¤×Ê
sele ......
½ñÌìÓöµ½¸öÓÐÒâ˼µÄÎÊÌ⣬ÊÇÒ»¸ö·Ö×éÅÅÐòµÄÎÊÌ⣬²»¹ýÒªÇó·Ö×éºÍ·Ö×é¼äÒ²ÒªÅÅÐò£¬Èç¹ûÕâ¸ö×éÄÚÓÐÒ»ÌõÊý¾ÝÊÇ×î½ü¸üеģ¬ÄÇôÕâÕû¸ö×鶼Ӧ¸ÃÅÅÔÚÇ°Ãæ¡£
ÏÂÃæÒÔOracleµÄHRʾÀýSchemaÖеÄemployees±íΪÀý£º
Óï¾ä°´²¿ÃÅ·Ö×飬·Ö×éÖ®¼äµÄÅÅÐòÊÇÕâÑùµÄ£ºÈç¹ûÕû¸ö·Ö×éÖÐÓÐÒ»¸öÔ±¹¤µÄhire_dateÊÇ×îеģ¬ÄÇôÕâ¸ö·Ö×é¾ÍÓ¦¸ÃÅÅÔÚÆä ......
Ò»¡¢sqlÊéд¹æ·¶£º
1¡¢sqlÓï¾äµÄËùÓбíÃû¡¢×Ö¶ÎÃûÈ«²¿Ð¡Ð´£¬ÏµÍ³±£Áô×Ö¡¢ÄÚÖú¯ÊýÃû¡¢sql±£Áô×Ö´óд¡£
2¡¢Á¬½Ó·ûor¡¢in¡¢and¡¢ÒÔ¼°£½¡¢<=¡¢>=µÈÇ°ºó¼ÓÉÏÒ»¸ö¿Õ¸ñ¡£
3¡¢¶Ô½ÏΪ¸´ÔÓµÄsqlÓï¾ä¼ÓÉÏ×¢ÊÍ£¬ËµÃ÷Ëã·¨¡¢¹¦ÄÜ¡£
&nb ......
SQL ServerÊý¾Ý²Ö¿âÏà¹Ø¸ÅÄî-ά¶È±íºÍÊÂʵ±í¸ÅÊö ÊÕ²Ø
¿ªÊ¼Ñо¿BI£¬³õѧ¡£»á¼Ç¼һЩ¸ÅÄîÐÔµÄÎÄÕ¡£
»ù±¾¸ÅÄ
1.¶àάÊý¾Ý¼¯£º¶àάÊý¾Ý¼¯ÊÇÁª»ú·ÖÎö´¦Àí (OLAP) ÖеÄÖ÷Òª¶ÔÏó£¬ÊÇÒ»Ïî¿É¶ÔÊý¾Ý²Ö¿âÖеÄÊý¾Ý½øÐпìËÙ·ÃÎʵļ¼Êõ¡£¶àάÊý¾Ý¼¯ÊÇÒ»¸öÊý¾Ý¼¯ºÏ£¬Í¨³£´ÓÊý¾Ý²Ö¿âµÄ×Ó¼¯¹¹Ô죬²¢×éÖ¯ºÍ»ã×ܳÉÒ»¸öÓÉÒ»×éά¶ÈºÍ¶ÈÁ ......
SQL Serverµ¼³ö±íµ½EXCELÎļþµÄ´æ´¢¹ý³Ì
·¢²¼Ê±¼ä£º2008.07.11 09:00 À´Ô´£ºÈüµÏÍø ×÷ÕߣºÐ¡ÇÇ
¡¾ÈüµÏÍø£IT¼¼Êõ±¨µÀ¡¿SQL Serverµ¼³ö±íµ½EXCELÎļþµÄ´æ´¢¹ý³Ì:
*--Êý¾Ýµ¼³öEXCEL
µ¼³ö±íÖеÄÊý¾Ýµ½Excel,°üº¬×Ö¶ÎÃû,ÎļþΪÕæÕýµÄExcelÎļþ
,Èç¹ ......