Mysql²éѯ·ÖÒ³
˵Ã÷£ºÕâÊÇÒ»¸öʵÀý£¬ÆäÖÐÓÐЩ¶«Î÷ÊÇ¿ÉÒÔ³éÈ¡³öÀ´µÄ£¬×÷Ϊһ¸ö¹«¹²µÄ·½·¨£¬¿ÉÊÇʵÏÖ¸´ÓÃ
public class TestService {
public static TestService test=null;
public static TestService getTestService(){
if(test==null){
test=new TestService();
}
return test;
}
public List getTest(int pageNow ,int pageSize){
String sql="select count(*) from user";
Connection conn=DB.getConn();
Statement stmt=DB.getStmt(conn);
ResultSet rs=DB.getRs(stmt, sql);
int num;
try {
rs.next();
num=rs.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
}
sql="select *from user limit "+(pageNow*pageSize-pageSize)+","+pageSize;
PreparedStatement pstmt=DB.getPstmt(conn, sql);
List list=new ArrayList<Test>();
try {
rs=pstmt.executeQuery(sql);
while(rs.next()){
Test t=new Test();
t.setId(rs.getInt("id"));
t.setAge(rs.getInt("age"));
t.setName(rs.getString("name"));
list.add(t);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
}
Ïà¹ØÎĵµ£º
×ÔÔö³¤ÀàÐÍÔö¼Ó
1.Èç¹ûdbmsÊÇMsSql,ÔòÑ¡¶¨±íºó£¬database-> edit current dbms-> ³öÏÖDBMS properties¶Ô»°¿ò£¬Ñ¡ÔñGeneralÒ³£¬×ó²àµÄÊ÷Ñ¡ÔñSQL 2000-> Profile-> Column-> Extended Attributes ÏÂÃæµÄExtIdentityIncrementÊDz½½ø ......
ÓкܶàÓ¦ÓÃÏîÄ¿, ¸ÕÆð²½µÄʱºòÓÃMYSQLÊý¾Ý¿â»ù±¾ÉÏÄÜʵÏÖ¸÷ÖÖ¹¦ÄÜÐèÇó£¬Ëæ×ÅÓ¦ÓÃÓû§µÄÔö¶à£¬Êý¾ÝÁ¿µÄÔö¼Ó£¬MYSQL½¥½¥µØ³öÏÖ²»¿°ÖظºµÄÇé¿ö£ºÁ¬½ÓºÜÂýÉõÖÁå´»ú£¬ÓÚÊǾÍÓаÑÊý¾Ý´ÓMYSQLǨµ½ORACLEµÄÐèÇó£¬Ó¦ÓóÌÐòÒ²ÒªÏàÓ¦×öһЩÐ޸ġ£±¾ÈË×ܽá³öÒÔϼ¸µã×¢ÒâÊÂÏϣÍû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
1.×Ô¶¯Ôö³¤µÄÊý¾ÝÀàÐÍ´¦Àí
MYSQLÓÐ ......
¡¡Ëæ×ÅÏÖ´úÊý¾Ý¿â¿ÉÓÃÌØÕ÷¼¯µÄѸËÙÔö¼Ó£¬ºÜÄÑÇø·ÖÊëºÃÊ뻵¡£ÀýÈçOracleÀï¾ÍÓÐÐí¶àÄã¿ÉÄÜ´ÓÀ´¶¼²»ÐèÒªµÄ¸ß¼¶Êý¾Ý²Ö¿âÌØÕ÷¡£´ËÍâÒ²¿ÉÄÜÓÐһЩÆäËü²»¿É»òȱµÄÌØÕ÷±ÈÈçACIDÊÂÎñÌØÐÔ¡£ÎÒÃÇÀ´¿´Ò»¿´Ö÷ÒªµÄһЩÌØÕ÷£¬±ÈÈç´æ´¢¹ý³Ì£¬ÊÓͼ£¬¿ìÕÕ£¬±íÊý¾ÝÀàÐͺÍÊÂÎñµÈµÈ¡£Í¬Ê±ÎÒÃÇ·ÖÎöÒ»ÏÂPostgresql£¬MySQLºÍOracleÕ⼸¸öÊý¾Ý¿â£¬È»º ......
mysql ¿ÉÒÔͨ¹ý×Ó²éѯµÃµ½ÒªÉ¾³ýµÄ¼Ç¼Ìõ¼þ£¬È»ºóͨ¹ý×Ó²éѯµÃ½á¹ûÆ¥ÅäҪɾ³ýµÄ¼Ç¼¡£µ«ÊÇ mysql ²»ÄÜÖ±½Óɾ³ý×Ó²éѯ±íÖеÄÊý¾Ý£¬±ØÐëͨ¹ýÒ»¸öÁÙʱ±íÀ´½â¾ö¡£ÀýÈ磺
delete from t_transaction where exists
(select d.* from t_ti_category a,t_category b,t_ ......
ÏÂÊÖ´¦£ºµÇ½mysql´Ó·þÎñÆ÷£¬Í¨¹ýÖ´ÐÐ mysql> show slave status\G ²é¿´ÆäÊä³ö£¬¼´¿ÉÅж¨Ö÷´Ó¸´ÖÆÊÇ·ñÕý³£¡£ÏÂÃæÊǼà¿ØMYSQL¸´ÖÆij¸ö´Ó·þÎñÆ÷µÄÊä³ö£º
mysql> show slave status\G
*************************** 1. row ***************************
&nbs ......