Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MYSQL] zmiana numeru id w tabeli...
Forum PHP.pl > Forum > Przedszkole
kkuubbaa88
mam tabele w ktorej jest pole id. jest to indeks tabeli oraz dodatkowo automatycznie wypełniany. Gdy tworze tabele numer startowy to 1 i co dodanie nowych danych on sam automatycznie sie wieksza o 1. teraz moje pytanie: czy gdy mam juz jakis tam numer np. 17 moge sobie jakos ustawic, aby zamielin sie np. na 10 i dalej sie sam pisal 11,12,13... ? czy tylko mozna od nowa tabele stworzyc i leciec od 1 ?
nospor
http://dev.mysql.com/doc/refman/5.0/en/alter-table.html
Cytat
To change the value of the AUTO_INCREMENT counter to be used for new rows, do this:
ALTER TABLE t2 AUTO_INCREMENT = value;
kkuubbaa88
no i wpisalem sobie w mysql
  1. ALTER TABLE aktualnosci_info AUTO_INCREMENT = 1;


ale numer nadal sie nie zmienil....
nospor
czemu zmieniles na 1? Mowiles ze na 10 chcesz. Nie masz w tabeli zadnych rekordow ze zmieniles na 1?

Cytat
You cannot reset the counter to a value less than or equal to any that have already been used. For MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum plus one. For InnoDB, you can use ALTER TABLE ... AUTO_INCREMENT = value as of MySQL 5.0.3, but if the value is less than the current maximum value in the column, no error occurs and the current sequence value is not changed.
kkuubbaa88
to juz wiele wyjasnia smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.