Single quote and boolean in PostgreSQL
- Input
- users: (1, Ana, true), (2, O'Brien, false)
- Expected output
- INSERT INTO users (id, name, active) VALUES (1, 'Ana', TRUE), (2, 'O''Brien', FALSE);
The surname's quote is doubled.
generate SQL INSERT statements with test data
Pick SQL as the format and your database's dialect: the generator writes the CREATE TABLE, the batched INSERTs and the foreign keys between tables. The four databases differ in small details, and that is where a generated script usually fails.
The surname's quote is doubled.
In MySQL the backslash is doubled so it does not become an escape.
The N prefix marks the literal as Unicode.
In MySQL the quotes would be backticks, and in SQL Server, brackets.
The last batch carries only what is left.
A space in place of the T and no trailing Z.
There is no fixed row limit beyond a safety ceiling of 100 million per table, which only guards against typos. The real limit is your device's memory and disk: data is generated in blocks of 2,000 rows and the browser builds the file piece by piece. In Chromium browsers, from 100,000 rows the tool asks for a location to write straight to disk, without gathering the whole file in memory. The estimated file size appears below the preview, computed from the sample, and you can cancel a long run at any time.
In PostgreSQL, use psql -f users.sql; in MySQL and MariaDB, mysql database_name < users.sql; in SQLite, sqlite3 app.db < users.sql; in SQL Server, sqlcmd -i users.sql. With several tables, run the files in the order they were generated (parents first) or use the .zip.
For hundreds of thousands of rows or more, a native CSV load is usually much faster than INSERTs: COPY in PostgreSQL, LOAD DATA in MySQL, .import in SQLite and bcp in SQL Server. INSERT is the better choice for small fixtures versioned with the code, because it is readable text and runs in any SQL client.
The tool guarantees distinct values within each generated table, and unique fields become UNIQUE in CREATE TABLE. If the database already held rows from an earlier load with the same seed, the values collide: change the seed, or start the id sequence at another number.
Fictitious data for testing. Documents only have the correct format and check digits, belong to no one and must not be used for fraud or to bypass verification. Cards and IBANs move no money.