How to get a desired store_id for a new store which is going to be published?
The store_id for the new store is pulled from the KEYS.COUNTER column. You need to edit the COUNTER column value corresponding to the column tablename='storeent' in KEYS table like below,
The new store_id is generated by value of "KEYS. COUNTER (column value) +1". To get a desired store_id, you can increase or decrease the present COUNTER column value from KEYS table as long as "COUNTER (column value) +1" value is not used in the STOREENT.STOREENT_ID column.
1. If you try to decrease the KEY.COUNTER column value to get a desired store_id, whenever you restart the server then KEY.COUNETR column value is increased by KEY.PREFETCHSIZE column value. So after restarting the server, if the new COUNTER (column value) +1 matches the STOREENT.STOREENT_ID then it will throw an error when you try create a new store.
2. Remember to backup the tables before doing an update.