Skip to content

Instantly share code, notes, and snippets.

@tmountain
Created March 8, 2013 15:23
Show Gist options
  • Save tmountain/5117190 to your computer and use it in GitHub Desktop.
Save tmountain/5117190 to your computer and use it in GitHub Desktop.
mysql> CREATE TABLE autoinc1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
^[[AQuery OK, 0 rows affected (0.35 sec)
mysql> CREATE TABLE autoinc2 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
Query OK, 0 rows affected (0.17 sec)
mysql> CREATE TABLE autoinc3 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
Query OK, 0 rows affected (0.18 sec)
mysql> set @@auto_increment_offset=1;
Query OK, 0 rows affected (0.00 sec)
mysql> set @@auto_increment_increment=10;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into autoinc1 values (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL);
Query OK, 12 rows affected (0.06 sec)
Records: 12 Duplicates: 0 Warnings: 0
mysql> set @@auto_increment_offset=2;Query OK, 0 rows affected (0.00 sec)
mysql> insert into autoinc2 values (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL);
Query OK, 12 rows affected (0.07 sec)
Records: 12 Duplicates: 0 Warnings: 0
mysql> set @@auto_increment_offset=3;Query OK, 0 rows affected (0.00 sec)
mysql> insert into autoinc3 values (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL);
Query OK, 12 rows affected (0.07 sec)
Records: 12 Duplicates: 0 Warnings: 0
mysql> select * from autoinc1;
+-----+
| col |
+-----+
| 1 |
| 11 |
| 21 |
| 31 |
| 41 |
| 51 |
| 61 |
| 71 |
| 81 |
| 91 |
| 101 |
| 111 |
+-----+
12 rows in set (0.00 sec)
mysql> select * from autoinc2;
+-----+
| col |
+-----+
| 2 |
| 12 |
| 22 |
| 32 |
| 42 |
| 52 |
| 62 |
| 72 |
| 82 |
| 92 |
| 102 |
| 112 |
+-----+
12 rows in set (0.00 sec)
mysql> select * from autoinc3;
+-----+
| col |
+-----+
| 3 |
| 13 |
| 23 |
| 33 |
| 43 |
| 53 |
| 63 |
| 73 |
| 83 |
| 93 |
| 103 |
| 113 |
+-----+
12 rows in set (0.00 sec)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment