Skip to content

sql_insert ​

Description ​

SQL INSERT or REPLACE statements containing literal rows. Configure sql_insert_table for the destination. Import the resulting text as SQL, not as INSERT ... FORMAT sql_insert.

Output only. Select it with FORMAT sql_insert. Names ignore ASCII case; use the snake_case name shown here.

The output is executable SQL with column names and literal row values. sql_insert_table names its destination, and other settings choose statement grouping and INSERT/REPLACE behavior.

Run the generated text as SQL to import it into a compatible existing table. It cannot be passed back through FORMAT sql_insert because this format has no input decoder.

text
SELECT expressions FORMAT sql_insert;

Example usage ​

sql
SELECT CAST(7 AS Int64) AS id, 'Ada' AS name FORMAT sql_insert;
text
INSERT INTO table (`id`, `name`) VALUES (7, 'Ada');

Format settings ​

Use a statement SETTINGS clause; these options are not persisted by SET.

Setting Type Default Meaning
sql_insert_batch_rows UInt64 65505 Write at most this many rows per INSERT or REPLACE statement; 0 writes one row per statement.
sql_insert_column_names Bool 1 Include the result column names before VALUES in each written statement.
sql_insert_quote_names Bool 1 Surround each written column name with backticks; names and the table text are otherwise written verbatim.
sql_insert_replace Bool 0 Write REPLACE INTO instead of INSERT INTO.
sql_insert_table String table The table text written verbatim after INSERT INTO or REPLACE INTO; include any desired qualification or quoting.