mysqlµÄ sequence µÄÎÊÌâ¡£ÔÚÏߵȴý¡£¡£
ÇëÎÊһϣ¬mysqlµÄsequenceÊÇ×Ô¶¯µÝÔöµÄ£¬²»ÐèÒª½øÐвÙ×÷¡£
ÄÇÎÒÔÚ²åÈëÒ»ÌõÖ÷¼Ç¼µÄʱºò£¬Í¬Ê±Òª¸øÕâ¸öÖ÷¼üµÄÆäËû±í½øÐвåÈëÊý¾Ý¡£Õâʱºò£¬ÎÒ¸ù±¾È¡²»µ½Õâ¸öµÝÔöµÄsequence°¢¡£¡£
Õâ¸öÎÊÌâÔõô½â¾ö°¢¡£¡£
ÄãÊÇÒª¸Õ²åÈëµÄÕâ¸ö×ÔÔöÖµÂð£¿
select last_insert_id();
»ò
select `auto_increment` from information_schema.tables where table_schema='¿âÃû' and table_name='±íÃû'
²åÈëºóÓÃLAST_INSERT_ID()È¡µÃ
ÓÃLAST_INSERT_ID()»á³öÎÊÌâÂ𣿣¿ Êý¾Ý¿âͬʱ²Ù×÷µÄ»°£¬Õâ¸öid»á²»»á±»±ðÈËÇÀµô°¡£¿£¿
²»»á
Ϊʲô°¡£¿£¿
ÓÐÈ˻شðÒ»ÏÂÂð£¿
Öصã: ¼ÙÈçÄãʹÓõ¥INSERTÓï¾ä²åÈë¶à¸öÐУ¬ LAST_INSERT_ID() Ö»·µ»Ø²åÈëµÄµÚÒ»ÐвúÉúµÄÖµ¡£ÆäÔÒòÊÇÕâʹÒÀ¿¿ÆäËü·þÎñÆ÷¸´ÖÆͬÑùµÄ INSERTÓï¾ä±äµÃ¼òµ¥¡£
ÀýÈ磺
mysql> INSERT INTO t VALUES
-> (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> SELECT * from t;
+----+------+
| id | name |
+----+------+
| 1 | Bob |
| 2 | Mary |
| 3 | Jane |
| 4 | Lisa |
+----+------+
4 rows in set (0.01 sec)
mysql> SELECT LAST_INSERT_ID();
+------------------+
| LAST_INSERT_ID() |
+------------------+
| &n
Ïà¹ØÎÊ´ð£º
×ö¸öÕ¾ÄÚËÑË÷£¬ÏÖÔÚÓÃlike ÕâÑùµÄЧÂÊʵÔÚÌ«µÍÁË£¬Ïë¸Ä³ÉÈ«ÎÄËÑË÷·½Ê½¡£
µ«¿´ÁËÍøÉÏ˵µÄÖÐÎÄÖ§³Ö²»ºÃ£¬ÏëÎÊһϸ÷λÐÖµÜÊÇÈçºÎ½â¾öÕâ¸öÎÊÌâµÄ£¿
µ¥¶À½¨Á¢Ö÷Ìâ±íºÍÄÚÈÝ±í ¼ìË÷Ö÷Ìâ
È»ºó¸ù¾ÝÖ÷Ìâ¼ìË÷Ä ......
jspÌá½»Ò³±àÂëÊÇUTF-8£¬MYSQL¿âÒ²ÊÇUTF-8,ΪʲôÌá½»ÁËÖÐÎÄ×Ö·ûÔÚÊý¾Ý¿âÀï±ä³ÉÂÒÂëÁËÄØ£¿
ÕâÖÖÎÊÌâÔõô½â¾ö£¿Ð»Ð»
ÁíÍ⣬JSPµ¯³ö¶Ô»°¿ò£¨±ÈÈ絯³ö¡°XXXÉóºËͨ¹ý¡±ÏÂÃæ¸úÈ·¶¨°´Å¥£©ºÍ·µ»ØÉÏÒ»Ò³ÒÔ¼°×ªµ ......
Java code:
public static void load(String filename) {
try {
@SuppressWarnings("unused")
Process process = Runtime.getRuntime().exec(
......
Õâ¸öÎÊÌâÀ§ÈÅÎҺþÃÁË£¬ÎÒÒ²²»ÖªµÀÔõôÎÊ£¬Ö»ÄÜ´óÖÂ˵һÏ£º
ÎÒÓÃMySQL´´½¨ÁËÒ»¸öÊý¾Ý¿â bookinfo±í£¬ÒªÓÃJavaµ÷ÓÃÕâÕÅ±í£¬µ«Êǵ÷Óò»³öÀ´£¬ÒªÊ²Ã´¾ä×Ó²ÅÄܵ÷ÓÃMySQL´´½¨µÄÊý¾Ý¿âÄØ¡£
Java code:
String url = ......
select time from table
time
2009-09-12 12
2009-09-12 13
2009-09-12 14
2009-09-12 15
Ôõô½« ²éѯµÄÊý¾Ý±äΪ
time
2009-09-12 12ʱ
2009-09-12 13ʱ
2009-09-12 14ʱ
......