Turn a Few PostgreSQL Rows into a Test Fixture with INSERT SQL
When a bug depends on two or three rows, a small reproducible fixture is easier to review than a whole dump. Select the relevant rows in a table grid, copy them as INSERT SQL, then retarget the statement to a disposable PostgreSQL table. Check the target, explicit columns, NULL values, and primary keys before reusing it.
Copy only the rows that reproduce the issue
In the SqlOtter table grid, select the relevant rows, right-click, and choose Copy INSERT Statement when that action is available. Paste the generated statement into a scratch editor and inspect its columns and values. Copying does not write to the database.

This historical MySQL screenshot shows where the command appears. The SQL below is a separate PostgreSQL example using synthetic values. Remove personal data before sharing a fixture or bug report.
Test NULL versus an empty string safely
Suppose an application treats a missing note and an empty note as the same value. The nullable note column should preserve that difference. Run this example in one session on a test connection:
BEGIN;
CREATE TEMP TABLE order_fixture (
id integer PRIMARY KEY,
status text NOT NULL,
note text
);
INSERT INTO pg_temp.order_fixture (id, status, note) VALUES
(101, 'pending', NULL),
(102, 'pending', '');
SELECT id, note IS NULL AS missing, length(note) AS note_length
FROM pg_temp.order_fixture
ORDER BY id;
ROLLBACK;
Row 101 returns missing = true and note_length = NULL. Row 102 returns missing = false and note_length = 0. The explicit pg_temp target keeps the insert and verification query pointed at the temporary fixture; ROLLBACK removes it.
Before reusing copied SQL, check for duplicate primary keys and generated or identity columns. An omitted column can receive its default; an explicit NULL is still supplied. When copying between database engines, review quoting, literals, and engine-specific syntax.
Disclosure: this article is published by the SqlOtter project account.
SqlOtter copy actions · PostgreSQL INSERT · PostgreSQL CREATE TABLE
About the author
- SqlOtter , The world's most powerful database management tool
Comments
Join the discussionNo comments yet. Be the first to comment.
SQL Table Filtering & Schema Inspection
Practical SQL database guides on filtering table data, finding loaded values, and inspecting table schemas with SqlOtter.

