Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¾«ÃîsqlÓï¾ä

1. ˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ£¬Ô´±íÃû£ºa£¬Ð±íÃû£ºb)
SQL: select * into b from a where 1<>1;
2. ˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý£¬Ô´±íÃû£ºa£¬Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d, e, f from b;
3. ˵Ã÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä
SQL: select a.title, a.username, b.adddate
from table a,(
select max(adddate) adddate
from table where table.title=a.title) b ¡¡

4. ˵Ã÷£ºÍâÁ¬½Ó²éѯ(±íÃû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; ¡¡

5. ˵Ã÷£ºÈճ̰²ÅÅÌáÇ°Îå·ÖÖÓÌáÐÑ
SQL: select *
from Èճ̰²ÅÅ
where datediff(’’minute’’, f¿ªÊ¼Ê±¼ä, getdate())>5 ¡¡¡¡

¡¡¡¡
6. ˵Ã÷£ºÁ½ÕŹØÁª±í£¬É¾³ýÖ÷±íÖÐÒѾ­ÔÚ¸±±íÖÐûÓеÄÐÅÏ¢
SQL: delete from info
where not exists(
select *
from infobz
where info.infid=infobz.infid );

7. ˵Ã÷£º——
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


Ïà¹ØÎĵµ£º

½â¾öSQL ServerתACCESS×Ô¶¯±àºÅÎÊÌâ


1.´ò¿ªSQL server enterprise mananger “ÆóÒµ¹ÜÀíÆ÷”
ÔÚÄãÒªµ¼³öµÄSQLÊý¾Ý¿âÉÏÊó±êÓÒ¼ü²Ëµ¥£ºËùÓÐÈÎÎñ-¡·µ¼³öÊý¾Ý
2.»Ø³öÏÖÒ»¸öµ¼³öÏòµ¼´°¿Ú¡£
Ñ¡Ôñ±»µ¼³öµÄÊý¾ÝÔ´£¬ÎªÄã¸Õ²ÅËùÑ¡ÔñµÄÊý¾Ý¿â£¬Èç¹û·¢ÏÖ²»¶ÔÓ¦×ÔÐÐÐ޸ġ£
3.½øÈëµ¼³öµ½Ä¿±êÊý¾ÝÔ´µÄÑ¡Ôñ£¬ÕâÀïÎÒÃÇҪת³ÉACCESSµÄÊý¾Ý¿â¡£×¢ÒâÑ¡ÔñÊý¾ÝÔ´ÀàÐÍÎ ......

JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,Oracle

import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
  
public static void main(String[] args)throws Exception {
  
   Connection conn=null;
  
       //====Á¬½ÓACCESSÊý¾Ý¿â ......

SQLSERVER SQLÐÔÄÜÓÅ»¯

1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......

SQLÓï¾äʾÀý

 --²éѯÊý¾Ý
SELECT *
from main_table;
--Ìí¼ÓÊôÐÔ
ALTER TABLE main_table
ADD AcctStop_Time SMALLDATETIME NULL;
--²åÈëÐÂÊý¾Ý
INSERT INTO main_table(Digital_ID, Letter_ID, User_Password, On_Line, IP, AcctStop_Time, FriendTable_UpdaeTime)
VALUES(10000000 + IDENT_CURRENT('main_table') + IDEN ......

OracleÀ©Õ¹PL/SQL¼ò½é(Áù)

8.    bulk collect /forall
ʹÓÃbulk collect¿ÉÒԳɿéµØ¶ÁÈ¡Êý¾Ý£¬Ëü¿ÉʹSQLÒýÇæÔÚ·µ»ØÊä³ö½á¹û¸øPL/SQLÒýÇæ֮ǰ´óÅú°ó¶¨Êä³ö¼¯ºÏ¡£ÕâÑù¿ÉÒÔÒ»´ÎÐԵذÑÊý¾Ý¶¯Ì¬µØ×°Ôص½¼¯ºÏÖУ¬µ«bulk collectÐèÒª´óÁ¿ÄÚ´æ¡£bulk collect¿ÉÓÃÓÚselect into¡¢fetch intoºÍreturning intoÓï¾äÖС£
¡ñ    se ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ