Ubercart order number start at 1. How can I set the order number to start with a larger number, e.g. 100001?
2 Answers
Run this query against your database:
ALTER TABLE uc_orders AUTO_INCREMENT = 100001;
The next record added will use 100001 as the ID.
Or for Postgres (Thanks @Mołot for the heads up):
SELECT setval('SEQUENCE_ID', 100001, FALSE);
You'll need to replace SEQUENCE_ID
with the appropriate sequence id for the uc_orders
table.
For sequence-enabled databases that lack setval (like Oracle, at least in some versions), you can:
ALTER SEQUENCE schema.sequence_id INCREMENT BY 1000;
SELECT schema.sequence_id.NEXTVAL FROM dual;
ALTER SEQUENCE schema.sequence_id INCREMENT BY 1;
-
1For PostgreSQL, Oracle and similar, one needs to use ALTER SEQUENCE instead. Can't find Drupal's default sequence names now.– MołotCommented May 22, 2013 at 14:37
-
Good point, thanks - I don't stray very far from Maria/MySQL with relational DBs these days, totally forgot about those– Clive ♦Commented May 22, 2013 at 14:40
-
Now we need someone with postgre & ubercart to update your answer with full query ;)– MołotCommented May 22, 2013 at 14:41
-
1Sequences works alike in both (in ibm db2 too), at least when all you want is to increment by 1, so your answer should be valid for pretty much any sequence-enabled database.– MołotCommented May 22, 2013 at 14:49
-
1Oh my, I forgot Oracle has some problems. Edited your answer to address them.– MołotCommented May 22, 2013 at 14:57
Other approach is to make order number not sequential. You may dislike the idea that user can count total orders between his orders - if he orders some minor stuff every month, he knows your monthly order volume, and that's bad. "Sanitization" of order number to prevent this was discussed here on ubercart.org.