> >Subject: [sqlite] How to determine ROWID of current > From: <[EMAIL PROTECTED]> > Date: Mon, 22 Nov 2004 19:52:40 -0800 > To: [EMAIL PROTECTED] > >The SQLite FAQ was very helpful regarding creation of an >AUTOINCREMENT field. > >It said we should declare a column (say colNum) INTEGER PRIMARY >KEY, which will then autoincrement. Seems to works fine. I've >deleted rows, but each new row added has a number one larger >than the greatest ever placed there. > >Is there a way to determine what number was (or will be) assigned >in colNum to a new INSERT, so that number could be used as a cross- >reference in another table or database? > >IOW, I suppose, is there an SQL query to quickly determine max >ROWID? > >If not, the FAQ says the API function named >sqlite_last_insert_rowid() which will return the integer key >for the most recent insert operation. Does that actually mean >the max ROWID on a table which has been opened but not yet >used? Or is that number returned only after once accessed? > >Thanks >
I think I answered my own long-winded question: SELECT max(ROWID) FROM table seems to work.