ddl

CREATE TABLE
ALTER TABLE
DROP TABLE

Three statements define the structure Everything else works inside it

create

CREATE TABLE targets (
  id INTEGER PRIMARY KEY,
  host TEXT NOT NULL,
  port INTEGER NOT NULL,
  severity TEXT NOT NULL
);

The GUI steps are gone The shape stayed

NOT NULL is a promise the database enforces Use it when empty data would be meaningless

foreign key

CREATE TABLE findings (
  id INTEGER PRIMARY KEY,
  target_id INTEGER NOT NULL,
  name TEXT NOT NULL,
  FOREIGN KEY (target_id) REFERENCES targets(id)
);

This ran successfully The constraint is active when the engine enforces it Check that enforcement is on before relying on it

alter

ALTER TABLE targets ADD note TEXT;

Adding a column is cheap Dropping one in a busy system is a planning exercise

drop

DROP TABLE removes the table and its data No confirmation prompt No undo outside a transaction

Next

Rows in 03 dml

Posted