MySQL allows DUAL to be specified as a table in queries that do not need data from any tables.The DUAL table is a special one-row, one-column table present by default in Oracle and other database installations.
What if I wanted to insert three rows of data with the same values from the select but different values for the 'additional' columns added such as email and current_time?
Inserting a NULL into a column with a NOT NULL constraint. Inserting a row to a partitioned table, but the values you insert don't map to a partition. If you use REPLACE, MySQL actually does a DELETE followed by an INSERT internally, which has some unexpected side effects: A new auto-increment ID is allocated.
Since the syntaxes are equivalent (in MySQL anyhow), I prefer the INSERT INTO table SET x=1, y=2 syntax, since it is easier to modify and easier to catch errors in the statement, especially when inserting lots of columns.
1896 I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the SQL engine of the day (MySQL, Oracle, SQL Server, Informix, and DB2).
LOAD DATA INFILE '/tmp/mydata.txt' INTO TABLE PerformanceReport; By default LOAD DATA INFILE uses tab delimited, one row per line, so should take it in just fine.
While searching for a way to insert array into single DB columns, I found an article about inserting JSON strings. However it wasn't explained how. I tried to search and find the way with no succes...
Both tables have the same schema All columns should transfer except for the auto-increment id Without explicitly writing all the column names, as that would be tedious The trivial INSERT INTO table_target SELECT * FROM table_source fails on duplicate entries for primary key.