Back to commands

Hosting Operations

Read-only

Show One SQLite Table Schema

You need to inspect the schema for one SQLite table.

Command

sqlite3 app.db ".schema users"

Before you run this

System impact: Read-only. Low when scoped to the shown target.

When not to use it: Do not use it as a migration history; it shows current schema, not how it got there.

Expected output

CREATE TABLE and related index statements for the users table.

System impact

Read-only. Nothing changes. The command prints schema statements for the selected table.

Recovery / rollback: no state is changed.

When to use it

Use before writing ad hoc SQL against a table you do not know well.

When not to use it

Do not use it as a migration history; it shows current schema, not how it got there.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

demo@lab:~$

$ sqlite3 app.db ".tables"

events  orders  schema_migrations  users

$ sqlite3 app.db ".schema users"

CREATE TABLE users (
  id INTEGER PRIMARY KEY,
  email TEXT NOT NULL,
  created_at TEXT NOT NULL
);
CREATE UNIQUE INDEX idx_users_email ON users(email);
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. sqlite3 app.db ".tables"
  2. sqlite3 app.db ".schema users"

next steps

Related commands

Hosting Operations Read-only

Count Rows in Key SQLite Tables

A quick row count can reveal empty imports, runaway events, or missing data.

sqlite3 app.db "SELECT 'users', count(*) FROM users UNION ALL SELECT 'orders', count(*) FROM orders UNION ALL SELECT 'events', count(*) FROM events;"
Hosting Operations Read-only

Find Duplicate Emails in SQLite

Duplicate account data is easier to spot with one grouped query.

sqlite3 app.db "SELECT email, count(*) FROM users GROUP BY email HAVING count(*) > 1;"
Hosting Operations Read-only

Show Indexes on a SQLite Table

Slow lookups often start with missing or misunderstood indexes.

sqlite3 app.db "PRAGMA index_list('orders');"
Hosting Operations Read-only

List SQLite User Tables Only

System metadata tables can distract from the app tables you care about.

sqlite3 app.db "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
Hosting Operations Read-only

Show Recent SQLite Events

For small apps, the quickest timeline may be inside the SQLite file.

sqlite3 app.db "SELECT created_at, event_type FROM events ORDER BY created_at DESC LIMIT 5;"
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lfcs:operations-deployment
  • lfcs:services-logs
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.