Is the "row ID" the same as the primary key?

7

The insert of Android returns a row ID according to the documentation,

  

the row ID of the newly inserted row, or -1 if an error occurred

The row ID corresponds to the primary key, ID , if it exists?

    
asked by anonymous 23.11.2017 / 12:40

1 answer

7

In some situations, yes.

  The primary key of a rowid table (if there is one) is usually not the primary key for the table, in the sense that it is not the unique key used by the underlying B-tree storage engine. The exception to this rule is when the rowid table declares an INTEGER PRIMARY KEY. In the exception, the INTEGER PRIMARY KEY becomes an alias for the rowid.

Font .

  

The PRIMARY key of a rowid table (if one exists) is generally not the true primary key for the table, as it is not the unique key used by the underlying B-tree storage engine. The exception to this rule is when the rowid table declares an INTEGER PRIMARY KEY. In the exception, the INTEGER PRIMARY KEY becomes an alias for rowid.

So your modeling can make it true or not. What is recommended to do so most of the time.

Useful too .

    
23.11.2017 / 12:48