1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Explore The Database Schema as a SQLite TIL

This commit is contained in:
jbranchaud
2024-12-17 12:28:13 -06:00
parent 43e6433fd6
commit a92af09fea
2 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
# Explore The Database Schema
The first thing I like to do when connecting to a database is get a quick lay
of the land. What are the tables and what do they look like?
I can list all tables with the `.tables` dot-command.
```sql
sqlite> .tables
ingredient_amounts ingredients recipes
```
I can then look at the `create table` statement for specific tables to see what
their schema looks like:
```sql
sqlite> .schema recipes
CREATE TABLE recipes (
id integer primary key,
name varchar not null,
description text not null,
instructions text not null
);
```
The `.schema` dot-command can also be used without any argument and it will
display the schema for all tables of all connected databases.
Run `.help` from the `sqlite3` prompt for more dot-command options.
[source](https://www.sqlite.org/cli.html#querying_the_database_schema)