SQLite Forum

Does table have rowid?
This query returns non-zero (true) if the table whose name is $TABLENAME
is a rowid table:

   SELECT count(*)==0 FROM pragma_index_info($TABLENAME);

The trick here is that a non-rowid table (that is to say a WITHOUT ROWID
table) is really implemented as a stand-alone index that has no associated
table.  So the the "PRAGMA index_info=TABLE" statement returns some information
about a WITHOUT ROWID table, since a WITHOUT ROWID table is implemented as an
index.  But a rowid table really is a table, and so "PRAGMA index_info"
returns no information about a rowid table.

Here is a query that will list all tables in the schema and show you for
each one whether or not it has a rowid:

   SELECT name,
          NOT EXISTS(SELECT 1 FROM pragma_index_info(x.name)) AS 'hasRowid'
     FROM sqlite_schema AS x
    WHERE type='table'
    ORDER BY name;