ignoring the valuse AUTO_INCREMENT in my table sql have a effect?
Hello !
please is ignoring the valuse AUTO_INCREMENT in my table sql have a effect to my current content ? thanks !!!
1 Answer
No, it won't. An AUTO_INCREMENT will keep a counter so that you can INSERT a row without specifying a value for that column.
If you ignore the AUTO_INCREMENT and do explicitly state a value for the column, the counter will be updated. The next insert without explicit value will take the previous insert into account - you don't risk a duplicate value. Testcase: Create the table: CREATE TABLE `counter` ( `1` int(11) NOT NULL auto_increment, PRIMARY KEY (`1`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;Insert a row, without stating the value: INSERT INTO `test`.`counter` (`1` ) VALUES (NULL);There will now be one row, with value 1. Insert another row, without stating the value: INSERT INTO `test`.`counter` (`1` ) VALUES (NULL);There will now be two rows, 1 and 2. Insert a row while explicitly stating the value: INSERT INTO `test`.`counter` (`1` ) VALUES ('8');You will now have three rows, 1, 2, 8 Now insert another row without stating the value: INSERT INTO `test`.`counter` (`1` ) VALUES (NULL);The new row will not have value 3 or 4, but the correct value 9: SELECT * FROM `counter`; 1 2 8 9 Posted: MacOS 2 of 2 people found this answer helpful. Did you? Yes No |
© Advanced Web Core. All rights reserved