consider this simple table(tbl1):
A|first letter B|second letter C|third letter
first column is letter and second column is desc
I can do this query without any problem:
select * from tbl1 where letter='B' -->>second letter
My question is: how I can get(retrieve) the ROWID of the result row?
ROWID doesn't enumerate the rows, it gives you the row ID, which is an internal ID used by sqlite, but ROW_NUMBER() is a function that generates sequential numbers for every result set.
SQLite has a special SQL function – last_insert_rowid() – that returns the ID of the last row inserted into the database so getting the ID of a new row after performing a SQL insert just involves executing the last_insert_rowid() command.
You should not use ROWID as the primary key of a table. If you delete and reinsert a row with the Import and Export utilities, for example, then its rowid may change. If you delete a row, then Oracle may reassign its rowid to a new row inserted later.
From the official documentation: “Rowids can change at any time and without notice. If you need to depend on your rowid, make it an INTEGER PRIMARY KEY, then it is guaranteed not to change”.
SELECT rowid, * FROM tbl1 WHERE letter = 'B'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With