SQLite - List columns in a table
by
Jeremy Canfield |
Updated: February 19 2023
| SQLite articles
The .schema command can be used to list the columns in a table. In this example, the columns in the users table in example.db are listed.
~]$ sqlite3 /path/to/example.db
SQLite version 3.34.1 2021-01-20 14:10:07
Enter ".help" for usage hints.
sqlite> .schema users
CREATE TABLE users (
id INTEGER NOT NULL,
date_created DATETIME,
email VARCHAR(100) NOT NULL,
password VARCHAR(200) NOT NULL,
PRIMARY KEY (id),
UNIQUE (id),
UNIQUE (email)
);
Or like this, as a oneliner command.
~]$ sqlite3 /path/to/example.db ".schema users"
CREATE TABLE users (
id INTEGER NOT NULL,
date_created DATETIME,
email VARCHAR(100) NOT NULL,
password VARCHAR(200) NOT NULL,
PRIMARY KEY (id),
UNIQUE (id),
UNIQUE (email)
);
Did you find this article helpful?
If so, consider buying me a coffee over at