# Tables and Rows: CREATE TABLE and INSERT

CREATE TABLE IF NOT EXISTS gives each column a type and rules such as NOT NULL, DEFAULT and CHECK that refuse bad rows, and INSERT adds rows with ? placeholders, one at a time with execute or many with executemany, with lastrowid giving the new row's id.

![Cheat sheet: Tables and Rows: CREATE TABLE and INSERT](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/560ebb5743b64f0b96794ee9b6d213ac.webp)

- Category: FastAPI
- Level: Apprentice
- Tags: CHECK Constraint, CREATE TABLE, database, DEFAULT Clause, INSERT, NOT NULL Constraint, Null, sql, sqlite
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/fastapi-sql-create-and-insert-cheat-sheet
