ÎÄ˼´´ÐµÄSQL±ÊÊÔÌâ
ÌâÄ¿£ºÓÐAºÍBÁ©¸ö±í£¬¶¼¶¨ÒåÏàͬµÄÖ÷¼ü£¬Ð´³öSQLÓï¾äÕÒ³öA±íÖÐÓжøB±íÖÐûÓеļǼ£¬È»ºó°ÑûÓеļǼ²åÈëµ½B±íÖС£
SQLÓï¾äÈçÏ£º
CREATE TABLE A_MINUS_B AS ---´´½¨Ò»¸ö²î¼¯±íA_MINUS_B ,×¢ÒâSELECT Óï¾äÒ»¶¨ÒªA±íÔÚǰ¡£
SELECT * from A
MINUS
SELECT * from B
INSERT INTO B(field1,field2,........) ----°Ñ²î¼¯²åÈëB±í£¬×¢Òâ²åÈëµÄ×Ö¶Î˳ÐòÒªÏàͬ£¬Êý¾ÝÀàÐÍÒ²ÒªÏàͬ¡£
SELECT field1,field2......
from A_MINUS_B
ÉÏÃæÓï¾äÔÚORACLE 10G ÒÔDEPT±íΪÊÔÑéÖ´Ðгɹ¦¡£Ò²¿ÉÄÜÓиü¸ßЧµÄ°ì·¨£¬´ó¼ÒÒ»ÆðÀ´ÌÖÂÛ¡£¿ÉÓÃÓαêÀ´´¦Àí°É£¬ÎÒ»¹Ã»Ñ§µ½Õⲿ·Ö¡£ÒÔºóÓÐÎһᲹÉÏ£¬µ±È»¸÷λ´óÏÀÒ²¿ÉÏÈдÉÏÁË¡£
insert into B select * from A where not exists(select 1 from B where B.KEYWORD = A.KEYWORD)
Ïà¹ØÎĵµ£º
1¡¢WINDOWSÉí·ÝµÇ½£º
<connectionStrings>
<add name="connectionString" connectionString="Data Source=(local);Initial Catalog=AngelicaDB;Integrated Security=True" providerName="System .Data .SqlClient" /> ......
select * from books
where 1=1
and categoryid=29
and title like('%ASP.NET%')
and unitprice>10
order by id
Select top 20 * from books order by id
--m:ÿҳÏÔʾÐÐÊý n£ºµ±Ç°Ò³Êý
select Top m * from books
where id not in
(Select top m(n-1) id from books order by id)
order by id
select * fro ......
½ñÌìÓöµ½¸öÓÐÒâ˼µÄÎÊÌ⣬ÊÇÒ»¸ö·Ö×éÅÅÐòµÄÎÊÌ⣬²»¹ýÒªÇó·Ö×éºÍ·Ö×é¼äÒ²ÒªÅÅÐò£¬Èç¹ûÕâ¸ö×éÄÚÓÐÒ»ÌõÊý¾ÝÊÇ×î½ü¸üеģ¬ÄÇôÕâÕû¸ö×é¶¼Ó¦¸ÃÅÅÔÚÇ°Ãæ¡£
ÏÂÃæÒÔOracleµÄHRʾÀýSchemaÖеÄemployees±íΪÀý£º
Óï¾ä°´²¿ÃÅ·Ö×飬·Ö×éÖ®¼äµÄÅÅÐòÊÇÕâÑùµÄ£ºÈç¹ûÕû¸ö·Ö×éÖÐÓÐÒ»¸öÔ±¹¤µÄhire_dateÊÇ×îеģ¬ÄÇôÕâ¸ö·Ö×é¾ÍÓ¦¸ÃÅÅÔÚÆä ......
SQL ServerÊý¾Ý²Ö¿âÏà¹Ø¸ÅÄî-ά¶È±íºÍÊÂʵ±í¸ÅÊö ÊÕ²Ø
¿ªÊ¼Ñо¿BI£¬³õѧ¡£»á¼Ç¼һЩ¸ÅÄîÐÔµÄÎÄÕ¡£
»ù±¾¸ÅÄ
1.¶àάÊý¾Ý¼¯£º¶àάÊý¾Ý¼¯ÊÇÁª»ú·ÖÎö´¦Àí (OLAP) ÖеÄÖ÷Òª¶ÔÏó£¬ÊÇÒ»Ïî¿É¶ÔÊý¾Ý²Ö¿âÖеÄÊý¾Ý½øÐпìËÙ·ÃÎʵļ¼Êõ¡£¶àάÊý¾Ý¼¯ÊÇÒ»¸öÊý¾Ý¼¯ºÏ£¬Í¨³£´ÓÊý¾Ý²Ö¿âµÄ×Ó¼¯¹¹Ô죬²¢×éÖ¯ºÍ»ã×ܳÉÒ»¸öÓÉÒ»×éά¶ÈºÍ¶ÈÁ ......
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].[ ......