Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MYSQL] zmiana numeru id w tabeli...
kkuubbaa88
post
Post #1





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

Ostrzeżenie: (0%)
-----


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 ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




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;
Go to the top of the page
+Quote Post
kkuubbaa88
post
Post #3





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

Ostrzeżenie: (0%)
-----


no i wpisalem sobie w mysql
  1. ALTER TABLE aktualnosci_info AUTO_INCREMENT = 1;


ale numer nadal sie nie zmienil....
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




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.
Go to the top of the page
+Quote Post
kkuubbaa88
post
Post #5





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

Ostrzeżenie: (0%)
-----


to juz wiele wyjasnia (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 13:44