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

±Ø±¸sqlÓï¾ä

 1.¶Á³ö±íÖеÄ×Ö¶ÎÃû
ResultSet  rs = test.selectSql("SELECT * from datainfo");  
java.sql.ResultSetMetaData md=rs.getMetaData();   //¶Á³öÊý¾Ý¿âµÄ×Ö¶ÎÃû
   int nColumn=md.getColumnCount();   //×Ö¶Î×ÜÊý
   for(int i=0;i<nColumn;i++)
  { 
  System.out.println(md.getColumnLabel(i+1));       //md.getColumnLabel(n)nÊÇ´Ó1¿ªÊ¼µÄ,´òӡÿ¸ö×Ö¶Î
  }
2.²éѯij¸öʱ¼ä¶ÎÄÚµÄÊý¾Ý
String sql="select * from datainfo where time between '"+start+"' and '"+end+"'";  ȡʱ¼ä¶ÎÄÚµÄÊý¾Ý
select * from datainfo where time between "2009-11-03 11:16:59"and "2009-11-03 11:18:59"
3.°´Ä³¸ö×ֶνµÐòÅÅÁв¢Ñ¡È¡µÚÒ»¸ö
sql="select * from datainfo,nodeinfo where nodeinfo.nodeid="+Integer.parseInt(param)+" and nodeinfo.nodeip=datainfo.ip
order by time desc limit 0,1"; °´Ê±¼ä½µÐòÅÅÁРֻȡµÚÒ»¸ö
£¨limit 0,1 ÊÇֻȡ¼Ç¼ÖеĵÚÒ»Ìõ.ËùÒÔÕâÌõÓï¾äÖ»Äܵõ½Ò»Ìõ¼Ç¼
  ÈçÏëÈ¡Ç°10ÌõÔò limit 0,10»òlimit 10
  ÈçÏëÈ¡µÚ10ÖÁ20ÌõÔò limit 10,20 £©
4.³öÏÖOperation not allowed after ResultSet closedµÄ´íÎó
    Ò»¸östmt¶à¸örs½øÐвÙ×÷.ÄÇô´ÓstmtµÃµ½µÄrs1,±ØÐëÂíÉϲÙ×÷´Ërs1ºó,²ÅÄÜÈ¥µÃµ½ÁíÍâµÄrs2,ÔÙ¶Ôrs2²Ù×÷.²»ÄÜ»¥ÏཻÌæʹÓÃ,»áÒýÆðrsÒѾ­¹Ø±Õ´íÎó.    ´íÎóµÄ´úÂëÈçÏÂ:
       stmt=conn.createStatement();
       rs=stmt.executeQuery("select * from t1");
       rst=stmt.executeQuery("select * from t2"); rs.last();
       //ÓÉÓÚÖ´ÐÐÁËrst=stmt.executeQuery(sql_a);rs¾Í»á±»¹Ø±Õµô£¡ËùÒÔ³ÌÐòÖ´Ðе½´Ë»áÌáʾResultSetÒѾ­¹Ø±Õ.
    ´íÎóÐÅϢΪ:java.sql.SQLException: Operation not allowed after ResultSet closed rst.last();
    ÕýÈ·µÄ´úÂë:
       stmt=conn.createStatement();
       rs=stmt.executeQuery("select * from t1");
     &n


Ïà¹ØÎĵµ£º

sqlÓï¾ä´´½¨³ÉµÇ¼

 1 windowsµÇ¼ÕË»§¿Ú£ºEXEC ap_grantlogin 'windowsÓòÃû\ÓòÕË»§'
 2 SQL µÇ¼ÕË»§:EXEC sp_addlogin 'ÕË»§Ãû','ÃÜÂë'
 3 ´´½¨Êý¾Ý¿âÓû§:exec spgrantdbaccess 'µÇ¼ÕË»§','Êý¾Ý¿âÓû§'
¶þ ¸øÊý¾Ý¿âÓû§ÊÚȨ
grant ȨÏÞ on ±íÃû to Êý¾Ý¿âÓû§ ......

sqlÓï¾ä£¬È¡³ö±íAÖеĵÚ31Ìõµ½40Ìõ¼Ç¼

 sqlÓï¾ä£¬È¡³ö±íAÖеĵÚ31Ìõµ½40Ìõ¼Ç¼£¨±íAÒÔ×Ô¶¯Ôö³¤µÄID×öÖ÷¼ü£¬×¢ÒâID¿ÉÄÜÊDz»Á¬ÐøµÄ£©
-->select top 10 * from a where id not in (select top 30 id from a order by id) order by id
    ²éѯǰʮÌõ¼Ç¼£¬µ«Ìõ¼þÊÇ£ºID²»ÔÚÇ°ÈýÊ®ÌõµÄIDÀïÃæ
-->select top 10 * from (select top 40 ......

»ùÓÚSQL Server ·ÖÒ³´æ´¢¹ý³ÌµÄÑݽø

 
»ùÓÚSQL Server ·ÖÒ³´æ´¢¹ý³ÌµÄÑݽø ÊÕ²Ø
Õë¶ÔÊý¾Ý¿âÊý¾ÝÔÚUI½çÃæÉϵķÖÒ³ÊÇÀÏÉú³£Ì¸µÄÎÊÌâÁË£¬ÍøÉϺÜÈÝÒ×ÕÒµ½¸÷Ö֓ͨÓô洢¹ý³Ì”´úÂ룬¶øÇÒÓÐЩ»¹¶¨ÖƲéѯÌõ¼þ£¬¿´ÉÏȥʹÓúܷ½±ã¡£±ÊÕß´òËãͨ¹ý±¾ÎÄÒ²À´¼òµ¥Ì¸Ò»Ï»ùÓÚSQL SERVER 2000µÄ·ÖÒ³´æ´¢¹ý³Ì£¬Í¬Ê±Ì¸Ì¸SQL SERVER 2005Ï·ÖÒ³´æ´¢¹ý³ÌµÄÑ ......

DB2ÁÙʱ±íÔÚSQL¹ý³Ì

 
°æȨÉùÃ÷£ºÔ­´´×÷Æ·£¬ÈçÐèתÔØ£¬ÇëÓë×÷ÕßÁªÏµ¡£·ñÔò½«×·¾¿·¨ÂÉÔðÈΡ£
DB2ÁÙʱ±íÔÚSQL¹ý³ÌºÍSQLÓï¾äÖеIJâÊÔ×ܽá
 
²âÊÔÄ¿±ê£º
 
·Ö±ðÔÚSQL¹ý³ÌºÍSQLÓï¾äÖд´½¨ÁÙʱ±í£¬²¢²åÈëÊý¾Ý£¬¿´Ö´Ðнá¹ûÓÐʲôÒìͬ¡£
 
²âÊÔ»·¾³£º
 
DB2 UDB V9.1
 
Ö´Ðи½¼þÀïÃæµÄSQLÓï¾ä£¬µÃµ½Ò»¸ö±í¡ ......

sql server 2000 È«ÎÄË÷ÒýÈ«½â

 http://hi.baidu.com/dumao/blog/item/1cafa71e5886d019413417e4.html
1.È«ÎÄË÷Òý¸ÅÊö
¶Ô Microsoft® SQL Server™ 2000 Êý¾ÝµÄÈ«ÎÄÖ§³ÖÉæ¼°Á½¸ö¹¦ÄÜ£º¶Ô×Ö·ûÊý¾Ý·¢³ö²éѯµÄÄÜÁ¦ºÍ´´½¨¼°Î¬»¤»ù´¡Ë÷ÒýÒÔ¼ò»¯ÕâЩ²éѯµÄÄÜÁ¦¡£
È«ÎÄË÷ÒýÔÚÐí¶àµØ·½ÓëÆÕͨµÄ SQL Ë÷Òý²»Í¬¡£
ÆÕͨ SQL Ë÷ÒýÈ«ÎÄË÷Òý
´æ´¢Ê±ÊÜ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ