How to Set Auto Increment That Start With Specific Values
- Create a table, let's say, here we want to create a transaction table. Here, you need to specifically state the specific value, for instance, 1000.
CREATE TABLE transactions (
transaction_id INT PRIMARY KEY AUTO_INCREMENT = 1000,
amount DECIMAL (5, 2)
)
- Insert a value into the table.
INSERT INTO transactons (amount)
VALUES (4.99);
SELECT * FROM transactions;
| transaction_id |
amount |
| 1000 |
4.99 |
- Try insert another value into the table to see how it work.
INSERT INTO transactons (amount)
VALUES (3.58);
SELECT * FROM transactions;
| transaction_id |
amount |
| 1000 |
4.99 |
| 1001 |
3.58 |
- So, you can continue adding the data from here.