Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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¡¢select 1 from mytable;Óëselect anycol(Ä¿µÄ±í¼¯ºÏÖеÄÈÎÒâÒ»ÐУ© from mytable;Óëselect * from mytable ×÷ÓÃÉÏÀ´ËµÊÇûÓвî±ðµÄ£¬¶¼ÊDz鿴ÊÇ·ñÓмǼ£¬Ò»°ãÊÇ×÷Ìõ¼þÓõġ£select 1 from ÖеÄ1ÊÇÒ»³£Á¿£¬²éµ½µÄËùÓÐÐеÄÖµ¶¼ÊÇËü£¬µ«´ÓЧÂÊÉÏÀ´Ëµ£¬1>anycol>*£¬ÒòΪ²»Óòé×Öµä±í¡£
2¡¢²é¿´¼Ç¼ÌõÊý¿ÉÒÔÓÃselect ......

DB2 SQL´æ´¢¹ý³ÌÓï·¨

 ±³¾°£ºDB2µÄÊý¾Ý¿âÐÔÄܺÜÅ£X£¬µ«ÊÇÆäÎĵµÈ´ºÜ²î£¬ÓÈÆäÊÇ¿ª·¢²Î¿¼Îĵµ£¬¶¼ÊÇÓ¢Îĵģ¬ä¯ÀÀµÄʱºò»¹ºÜ²»ºÃÕÒ£¬ÐèÒªÉÏIBMµÄÍøÕ¾¿´£¬ÍøÕ¾Ò²³öÆæµÄÂý£¬¼«²»·½±ã£¬Èÿª·¢ÈËÔ±¾Ù²½Î¬¼è£¬ÕâÒ²ÐíÊÇIBM DB2µÄÓû§ÉÙ£¬ÊéÉÙ£¬×ÊÁÏÉÙµÄÔ­Òò¡£
£­£­£­£­£­£­£­£­£­£­£­£­£­£­£­£­£­£­
´´½¨SQL´æ´¢¹ý³Ì£¨CREATE PROCEDURE (SQL) stat ......

SQLÖÐCONVERTת»¯ÈÕÆÚº¯ÊýµÄʹÓ÷½·¨

SQLÖÐCONVERTº¯Êý×î³£ÓõÄÊÇʹÓÃconvertת»¯³¤ÈÕÆÚΪ¶ÌÈÕÆÚ
Èç¹ûֻҪȡyyyy-mm-dd¸ñʽʱ¼ä, ¾Í¿ÉÒÔÓà convert(nvarchar(10),field,120)
120 ÊǸñʽ´úÂë, nvarchar(10) ÊÇָȡ³öÇ°10λ×Ö·û.
SELECT CONVERT(nvarchar(10), getdate(), 120)
SELECT CONVERT(varchar(10), getdate(), 120)
SELECT CONVERT(char(10), ge ......

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

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