phpMyAdmin
 sql >> Datenbank >  >> Database Tools >> phpMyAdmin

So importieren Sie eine Textdatei in eine Tabelle mit Primärschlüssel als Autoinkrement

Eine andere Methode, die ich verwende, die keine Neuordnung der Felder einer Tabelle erfordert (vorausgesetzt, das Auto-Increment-Feld ist die erste Spalte), lautet wie folgt:

1) Open/import the text file in Excel (or a similar program).

2) Insert a column before the first column. 

3) Set the first cell in this new column with a zero or some other placeholder.

4) Close the file (keeping it in its original text/tab/csv/etc. format).

5) Open the file in a text editor.

6) Delete the placeholder value you entered into the first cell.

7) Close and save the file.

Jetzt haben Sie eine Datei, die jede Zeile Ihrer Originaldatei enthält, der eine leere Spalte vorangestellt ist, die beim Import über phpMyAdmin in den nächsten relevanten Auto-Increment-Wert umgewandelt wird.