INSERT
Sintassi
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] nome_tabella [(nome_colonna, ...)]
{VALUES | VALUE} ({espr | DEFAULT}, ...), (...), ...
[ ON DUPLICATE KEY UPDATE
nome_colonna=espr
[, nome_colonna=espr] ... ]
Oppure:
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] nome_tabella
SET nome_colonna={espr | DEFAULT}, ...
[ ON DUPLICATE KEY UPDATE
nome_colonna=espr
[, nome_colonna=espr] ... ]
Oppure:
INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
[INTO] nome_tabella [(nome_colonna, ...)]
SELECT ...
[ ON DUPLICATE KEY UPDATE
nome_colonna=espr
[, nome_colonna=espr] ... ]
Spiegazione
INSERT inserisce nuove righe in una tabella esistente. Le forme INSERT ... VALUES e INSERT ... SET inseriscono le righe basandosi su valori forniti esplicitamente. La forma INSERT ... SELECT inserisce le righe selezionate da un'altra tabella o da altre tabelle. INSERT ... SELECT è spiegata nel dettaglio alla pagina INSERT ... SELECT.
Nota: con INSERT è possibile inserire più righe con un solo comando, in questo modo:
INSERT INTO nome_tabella values(1,"riga 1"),(2, "riga 2");
Vedi anche
Commenti
Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.