what is the primary key of a table?

jerryt
Tera Contributor

Hi there,

I'm using Helsinki and I'm wondering what is the primary key in a table.

It looks that most of the tables have a column 'sys_id', which seems like the primary key in that table. When I navigate to 'Tables and Columns', I see a big blue circle icon with an 'i' inside beside sys_id: pk.PNG

But some tables don't have sys_id. For example, pa_favorites and v_db_index seem not to have primary keys.

There's another interesting table. ts_word_roots has 3 columns and they are like this:

ts_word_roots.PNG

So my questions are:

1. How can I check what is the primary key in a table? (usually sys_id I guess, but I'm not sure)

2. Are there any tables without primary keys? (like pa_favorites and v_db_index?)

3. For table ts_word_roots, does it have a composite primary key?

Thanks a lot!

1 ACCEPTED SOLUTION

Hi Jerry,



Yes, where there is a sys_id, that's the primary key. I checked some of the others you mentioned and here's what I found.


  • pa_favorites - PRI=user
  • v_db_index - PRI=sys_id
  • ts_word_roots - PRI=index,raw_word,stemmed_word


Let me know if there are any other specifics you need.


View solution in original post

11 REPLIES 11

Hi Jerry,



Each record in ServiceNow is identified by a unique 32-character GUID (Globally Unique ID) called a sys_id. The same sys_id value will never be generated twice, ensuring every record created in every table in every instance of ServiceNow in the world has a unique identifying value.



For other tables which don't have sys_id you can define unique index. Please refer below link for more info.


http://wiki.servicenow.com/index.php?title=Unique_Index#gsc.tab=0


Thanks.