CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Where is CiviCRM id stored?
Pages: [1]

Author Topic: Where is CiviCRM id stored?  (Read 600 times)

clarkac

  • Administrator
  • Ask me questions
  • *****
  • Posts: 399
  • Karma: 11
  • CiviCRM version: 4.4.11 & 4.5.5
  • CMS version: Drupal 7
  • MySQL version: 5.1.61-cll
  • PHP version: 5.3.27
Where is CiviCRM id stored?
April 30, 2013, 01:43:22 pm
Can anyone tell me in what table the CiviCRM id is stored?  This is the unique numerical ID of the contact, and seems to be called GID in these forums...

I would like to see if I can set this to a higher number so I can start these IDs off at a given number.
Andy Clark

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Where is CiviCRM id stored?
April 30, 2013, 02:28:20 pm
hi - the Contact ID or internal ID is usually referred to as the cid (if anything)

gid is usually the id of a profile

i think this caused confusion on http://forum.civicrm.org/index.php/topic,28578.0.html and it might help others if you could amend that posting ;-)
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Where is CiviCRM id stored?
April 30, 2013, 02:29:49 pm
oh - and to answer your question  :P

it is in the table civicrm_contact - field is 'id'
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Where is CiviCRM id stored?
April 30, 2013, 02:31:50 pm
and to answer the other question - a non-technical solution .... check your highest current id - run an import to create the intervening numbers and then delete them - gets you to your starting point

someone else may come along with a sql solution but the above should stop you being stumped if you need a non-techy work around

hth
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

clarkac

  • Administrator
  • Ask me questions
  • *****
  • Posts: 399
  • Karma: 11
  • CiviCRM version: 4.4.11 & 4.5.5
  • CMS version: Drupal 7
  • MySQL version: 5.1.61-cll
  • PHP version: 5.3.27
Re: Where is CiviCRM id stored?
May 01, 2013, 12:48:44 am
Thanks for that.  I thought there would be a master record with the latest ID number stored in a single row table somewhere.
I have modified my misleading forum items...
Andy Clark

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Where is CiviCRM id stored?
May 01, 2013, 12:51:08 am
i believe that is what you would describe as 'the master record'

any contact has a 'contact record' hence has a row in civicrm_contact with their cid
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Where is CiviCRM id stored?
May 01, 2013, 02:13:05 am
Hi,

the contact id (and pretty much all the ids in civi in general) is an auto increment column. It's a mysql feature that when you create a new record, it will automatically fill it with the next available number. On other databases, you have that that next number stored into a SEQUENCE, in mysql it's embedded into the column definition.


In general, you shouldn't make any assumption about what this number is. if you want an id to store external identifiers to sync with another system, use the external_identifier, that's what it's for.


Anyway, to set the value of the id:

ALTER TABLE civicrm_contact AUTO_INCREMENT = 42; //or whatever number

You might want to read mysql doc to check under which condition it's safe (it's close to the metal, so potentially might have bad side effects, eg if you have ids greater to whatever you want to se) and again if you aim is to sync with another database, use the external_identifier.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Where is CiviCRM id stored?

This forum was archived on 2017-11-26.