9951 explained code solutions for 126 technologies


sqliteHow do I get the column names of a SQLite database?


To get the column names of a SQLite database, you can use the PRAGMA table_info statement. This statement returns the column names, data types, and other information about the columns in a given table.

For example, to get the column names of a table called people:

sqlite> PRAGMA table_info(people);
0|name|text|1||0
1|age|integer|0||0
2|gender|text|0||0

The output of the PRAGMA table_info statement consists of the following parts:

  • 0: The column number
  • name: The column name
  • text: The data type of the column
  • 1: A flag indicating whether the column is NOT NULL
  • 0: A flag indicating whether the column is a PRIMARY KEY
  • 0: A flag indicating whether the column has a DEFAULT VALUE

Helpful links

Edit this code on GitHub