Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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»ù±¾Óï·¨

 Select * from tableName
exec('select * from tableName')
exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
declare @fname varchar(20)
set @fname = 'FiledName'
Select @fname from tableName -- ´íÎó,²»»áÌáʾ´í ......

ÏÂÃæÊÇÎÒËѼ¯µÄһЩ¾«ÃîµÄSQLÓï¾ä

ÏÂÃæÊÇÎÒËѼ¯µÄһЩ¾«ÃîµÄSQLÓï¾ä¡£
˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb)
SQL: select * into b from a where 1<>1
˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d,e,f from b;
˵Ã÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä
SQL: select a.title,a.username,b.adddat ......

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

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

1.The SQL introuduction

Introducing Oracle Database 11g
List the features of Oracle Database 11g
Discuss the basic design, theoretical and physical aspects of a relational database
Categorize the different types of SQL statements
Describe the data set used by the course
Log onto the database using the SQL Develope ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ