SQLite – How to get the primary key column name for a given table?

All I know is the name of the table and the id value of the query I want to execute, but I don’t know what id is called in the table.
You can use the answer to a quite similar question to find the column name of the primary key column.

sqlite> pragma table_info(...)

If needed, it should also work programmatically.

All I know is the table name and what I want to execute The id value of the query, but I don’t know what the id is called in the table.

You can use the answer to a quite similar question to find the column name of the primary key column.

sqlite> pragma table_info(...)

If needed, it should also work programmatically.

Leave a Comment

Your email address will not be published.