1

I am running a new site with Drupal 7.

I want the node ID to start with 100,000.

How do I set it? I don't want the node start with node 1.

0

1 Answer 1

4

To make node IDs start from 100000, in a new site (which I assume doesn't have any nodes created yet), all that's needed is to run this SQL statement (assuming you're using MySQL, PostgreSQL or SQLite):

  • For MySQL or SQLite:

    ALTER TABLE node AUTO_INCREMENT = 100000;

  • For PostgreSQL, and inspired by the accepted answer to "Reset auto increment counter in Postgres", it should be something like so:

    ALTER SEQUENCE node_nid_seq RESTART WITH 100000;

Change the 100000 value in this SQL to any other value (like 123), to make node IDs start from that other value (like 123).

Caution when applying such change in an existing site, whereas the new node ID (like 123) is less then the highest node ID used already in your site. Because in that case you may get all sorts of effects you may not want/like ... Though in a new site (as in this question here) those effects don't apply.

3
  • 2
    I think this answer is only correct for MySQL. MySQL, PostgreSQL, and SQLite are all officially supported by Drupal 7, and handle auto increment fields in different manners and have different syntax for resetting this value. However, I do not recall exactly how the 'type' => 'serial' fields get handled for the non-MySQL drivers (since I never use them).
    – mpdonadio
    Sep 26, 2015 at 16:17
  • @MPD : I've enhanced my answer to address your prior comment ... Jul 26, 2016 at 9:30
  • @Pierre.Vriens, your answer fixed my PRODUCTION SERVER issue. Found every where on Google, cannot find any accurate solution close to yours one. Thanks buddy. This is the reason why I appreciate StackOverflow sites.
    – Pupil
    May 9, 2022 at 5:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.