Bootstrap FreeKB - SQLite - List columns in a table
SQLite - List columns in a table

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter aebcae in the box below so that we can be sure you are a human.