Insertar o actualizar sql

Ejemplos de código

1
0

insertar o actualizar sql

-- Oracle: Example for Insert or update in t1 from t2 values 
MERGE INTO table1 t1
USING table2 t2
ON (t1.CODE = t2.ID)
WHEN MATCHED THEN
    UPDATE SET t1.COL1 = t2.VALUE1
WHEN NOT MATCHED THEN
    INSERT (CODE, COL1)  VALUES (t2.ID, t2.VALUE1);

-- MySql (makes a INSERT + DELETE if existing)
REPLACE INTO table1 (pk_id, col1) VALUES (5, 'aaaa');
--
INSERT IGNORE INTO table1 VALUES (key, generation)
ON DUPLICATE KEY UPDATE (key = key, generation = generation + 1);

Páginas relacionadas

Páginas de ejemplo relacionadas

En otros idiomas

Esta página está en otros idiomas

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................