SQLÓï¾ä
Ç°¶Îʱ¼äѧµÄÓйØsqlµÄÏà¹Ø֪ʶ,ºÜ¶à¶¼Ã»¼°Ê±È¥ÕûÀí,½ñÌì¸ÕºÃÓÐʱ¼äÓÐûÐÄÇé×öÆäËûµÄÊÇ,¾ÍÕûÀíÕûÀí°É
Ò»Ö±ÒÔΪ×ö¿ª·¢µÄ¶ÔÊý¾Ý¿â²Ù×÷·½ÃæµÄÒªÇó²»»áºÜ¸ß,Ö»Òª»á¶ÔÊý¾ÝÔöɾ¸Ä²é¾ÍokÁË.ÏÖÔÚ²ÅÖªµÀ¶ÔÊý¾Ý¿âµÄ²Ù×÷»¹Ó¦¸Ã°üÀ¨Ð´´æ´¢ºÍº¯Êý,»¹Òª´´½¨ÐòÁС¢Ë÷Òý,ÊÓͼµÈ.
Ê×ÏÈ,»¹Êǽ²ÐòÁÐ, ÐòÁÐÊÇOracle 9iÌṩµÄÓÃÓÚ°´ÕÕÉ趨µÄ¹æÔò×Ô¶¯²úÉúÊý¾ÝµÄ·½°¸¶ÔÏó¡£ÔÚijЩÊý¾Ý±íµÄ½á¹¹ÖУ¬ÓÐЩ×Ö¶ÎÐèÒªÕâÖÖÌØÐÔ¡£±ÈÈ磬¶ÔÓÚij¸öѧÉúÊý¾Ý±íµÄѧºÅ¹Ø¼ü×ֶΣ¬Óû§¿ÉÒÔÏ£ÍûÔÚ¼ÈëÊý¾Ýʱ£¬Äܹ»×Ô¶¯ÔÚÉÏÒ»¸ö¼Ç¼µÄѧºÅ×Ö¶ÎÉÏ×Ô¶¯¼Ó1µÈ.×ÜÖ®ÐòÁоÍÊÇÄãΪÁÐÉ趨ÄãÏëÒªµÄÔö³¤·½Ê½
¸ñʽΪ:
create sequence hibernate_sequence <------ÐòÁÐÃû
increment by 1 <------²½³¤
start with 1 <------¿ªÊ¼Öµ
maxvalue 999999 <----×î´óÖµ
Æä´ÎÊÇÊÓͼ, ÊÓͼ¿ÉÒÔ±»¿´³ÉÊÇÐéÄâ±í»ò´æ´¢²éѯ¡£¿Éͨ¹ýÊÓͼ·ÃÎʵÄÊý¾Ý²»×÷Ϊ¶ÀÌصĶÔÏó´æ´¢ÔÚÊý¾Ý¿âÄÚ¡£Êý¾Ý¿âÄÚ´æ´¢µÄÊÇ SELECT Óï¾ä¡£SELECT Óï¾äµÄ½á¹û¼¯¹¹³ÉÊÓͼËù·µ»ØµÄÐéÄâ±í¡£Óû§¿ÉÒÔÓÃÒýÓñíʱËùʹÓõķ½·¨£¬ÔÚ Transact-SQL Óï¾äÖÐͨ¹ýÒýÓÃÊÓͼÃû³ÆÀ´Ê¹ÓÃÐéÄâ±í¡£Ê¹ÓÃÊÓͼ¿ÉÒÔʵÏÖÏÂÁÐÈÎÒ»»òËùÓй¦ÄÜ£º
¡¡¡¡½«Óû§ÏÞ¶¨ÔÚ±íÖеÄÌض¨ÐÐÉÏ¡£
¡¡¡¡ÀýÈ磬ֻÔÊÐí¹ÍÔ±¿´¼û¹¤×÷¸ú×Ù±íÄڼǼÆ乤×÷µÄÐС£
¡¡¡¡½«Óû§ÏÞ¶¨ÔÚÌض¨ÁÐÉÏ¡£
¡¡¡¡ÀýÈ磬¶ÔÓÚÄÇЩ²»¸ºÔð´¦Àí¹¤×ʵ¥µÄ¹ÍÔ±£¬Ö»ÔÊÐíËûÃÇ¿´¼û¹ÍÔ±±íÖеÄÐÕÃûÁС¢°ì¹«ÊÒÁС¢¹¤×÷µç»°ÁкͲ¿ÃÅÁУ¬¶ø²»ÄÜ¿´¼ûÈκΰüº¬¹¤×ÊÐÅÏ¢»ò¸öÈËÐÅÏ¢µÄÁС£
¡¡¡¡½«¶à¸ö±íÖеÄÁÐÁª½ÓÆðÀ´£¬Ê¹ËüÃÇ¿´ÆðÀ´ÏóÒ»¸ö±í¡£
¡¡¡¡¾ÛºÏÐÅÏ¢¶ø·ÇÌṩÏêϸÐÅÏ¢¡£
¡¡¡¡ÀýÈ磬ÏÔʾһ¸öÁеĺͣ¬»òÁеÄ×î´óÖµºÍ×îСֵ¡£
¸ñʽΪ
create view viewname
 
Ïà¹ØÎĵµ£º
SQL SERVER 2008 ¸ü¸Ä¸ú×Ù
/*
¿´Ê飬¿´Áª»úÆڼ䡣¡£¡£Ë³´ø°Ñ¿´µ½µÄдÏÂ
ÓëSQL SERVER 2008 CDC Òì²½²¶»ñÊý¾Ý±ä¸üµÄ²»Í¬,¸ü¸Ä¸ú×ÙÊÇͬ²½½ø³Ì,
ÊÇDML(INSERT/UPDATE/DELETE)ÊÂÎñµÄÒ»²¿·Ö,Ëü¿ÉÒÔʹÓÃ×îСµÄCÅÌ´æ´¢
¿ªÏúÀ´Õì²âÊý¾ÝÐеľ»±ä¸ü.ÄÇôËüÒ²¾Í²»ÄÜÏñCDCÄÇÑù¿ÉÒÔÌṩÓû§±íµÄ
ÀúÊ·¸ü¸ÄÐÅÏ¢. ¸ü¸ÄÊÇʹÓÃÒ ......
¶ÔÓÚÓÐÖ÷¼ü×Ô¶¯Ôö³¤Êý¾Ý¿â±í£¬ÔÚ½øÐзÖÒ³ÉèÖÃʱ£¬ÎÒÈÏΪ»¹±È½Ï²»´íµÄÊÇ£º
SELECT TOP Ò³´óС *
from TestTable
WHERE (ID >
(SELECT MAX(id)
from (SELECT TOP Ò³´óС*Ò³Êý id
  ......
sqlͳ¼Æ£¹ØÓÚѧÉú³É¼¨(´ð°¸)
http://blog.sina.com.cn/s/blog_61380b320100ej9p.html
´ð°¸£º
1. ¼ÆËãÿ¸öÈ˵Ä×ܳɼ¨²¢ÅÅÃû
select name,sum(score) as allscore from stuscore group by name order by allscore
2. &nbs ......
##################################################
# ÉùÃ÷£º
# ±¾ÎÄת×ÔCSDN£¬Óû§ID£ºhtl258
# ÔÌûµØÖ·£ºhttp://blog.csdn.net/htl258/archive/2010/05/13/5588454.aspx
####### ......