- For tables with primary keys, if you insert a row with an existing key, the new row will overwrite the existing row.
- Call FLUSH after
INSERTto persist the changes to storage. This ensures that the changes are committed and visible for subsequent reads.
Syntax
Parameters
| Parameter or clause | Description |
|---|---|
| table_name | The table where you want to insert rows. |
| col_name | The column where you want to insert corresponding values. Currently, you must provide all columns in the table in order or leave this field empty. |
| value | An expression or value to assign to the corresponding column. You can use DESCRIBE to check the order of the columns in the table. |
| select_query | A SELECT statement that returns the rows you want to insert to the table. |
| RETURNING | Returns the values of any column based on each inserted row. |
Example
The tabletaxi_trips has three columns:
taxi_trips.
taxi_trips_new into taxi_trips. The two tables have the same column setup. Also, it returns the value of id for the inserted rows.