Generate data as an INSERT script
Oracle
-- DBMS_METADATA for object DDL
SELECT DBMS_METADATA.GET_DDL('TABLE','CUSTOMER') FROM dual;
-- Generating row data as INSERTs is not built in;
-- use SQL Developer 'Export > Insert' or SQLcl 'SET SQLFORMAT INSERT':
-- SET SQLFORMAT INSERT
-- SELECT * FROM customer;Oracle offers no SQL command that converts data directly into a ready INSERT script. For DDL use DBMS_METADATA.GET_DDL; for row INSERTs use SQLcl (SET SQLFORMAT INSERT) or the SQL Developer Export wizard.
PostgreSQL
-- Data only, as INSERT statements
pg_dump --data-only --inserts --table=customer shop > insert.sql
-- With column names (more robust to schema differences)
pg_dump --data-only --column-inserts --table=customer shop > insert.sqlpg_dump --inserts writes each row as a separate INSERT; --column-inserts also adds column names (robust to schema differences). The default (no flag) produces COPY format, which loads much faster.
MySQL
-- Data only (INSERTs), without the table definition
mysqldump --no-create-info shop customer > insert.sql
-- One INSERT per row (more readable)
mysqldump --no-create-info --skip-extended-insert shop customer > insert.sqlmysqldump produces INSERT statements by default; --no-create-info skips CREATE TABLE and outputs data only. --skip-extended-insert makes each row a separate INSERT (the default combines many rows into one statement).
SQL Server
-- SSMS: right-click > Tasks > Generate Scripts >
-- Advanced > 'Types of data to script' = Data only (or Schema and data)
-- Command-line alternative (sqlpackage / mssql-scripter tool)
-- mssql-scripter -S server -d shop -t customer --data-only > insert.sqlSQL Server has no built-in T-SQL command for this. The most common way is to choose Data only in the SSMS 'Generate Scripts' wizard. On the command line, Microsoft's mssql-scripter tool generates INSERTs with --data-only.
MongoDB
# Produces a binary/BSON backup instead of INSERT SQL
mongodump --db=shop --collection=customer --out=./backup
# As JSON text (can be adapted to insertMany)
mongoexport --db=shop --collection=customer --jsonArray --out=customer.jsonThere is no SQL INSERT concept. For a portable backup use mongodump (BSON, restored with mongorestore). For an insertMany embedded in code, the output of mongoexport --jsonArray can be used.
Redis
# Portable serialization of a single key
DUMP customer:1
# The output is restored with RESTORE:
# RESTORE customer:1 0 "<dump-data>"
# RDB snapshot for all data
redis-cli --rdb dump.rdbNo SQL INSERT script is produced. Use DUMP + RESTORE serialization per key and an RDB (--rdb) file for all data. If a command list is needed, iterate with SCAN and build the appropriate SET/HSET commands for each type.
Elasticsearch
# The INSERT equivalent is _bulk NDJSON; produce it with elasticdump
elasticdump --input=http://localhost:9200/customer --output=customer_bulk.json --type=data
# Manual: converting a _search result to _bulk NDJSON requires an external scriptNo SQL INSERT is produced; in Elasticsearch the unit of loading is _bulk NDJSON. To extract existing data in a reloadable form, use elasticdump (type=data); _search + PIT output can be converted to NDJSON with an external script.