Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> LOCK_TABLES i TRUNCATE, czy da sie sprawic by TRUNCATE dzialalo
sobstel
post
Post #1





Grupa: Zarejestrowani
Postów: 853
Pomógł: 25
Dołączył: 27.08.2003
Skąd: Katowice

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


wykonanie ponizszeg kodu

  1. <?php
  2.  
  3. mysql_query('LOCK TABLES table WRITE');
  4. mysql_query('TRUNCATE TABLE table');
  5. mysql_query('UNLOCK TABLES');
  6.  
  7. ?>


skutkuje wystapieniem nastepujacego bledu :

Fatal error: 1192:Can't execute the given command because you have active locked tables or an active transaction


Czy jest jakis sposob na uzycie TRUNCATE po zablokowaniu tabeli?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
markac
post
Post #2





Grupa: Zarejestrowani
Postów: 83
Pomógł: 0
Dołączył: 23.02.2005

Ostrzeżenie: (10%)
X----


Zastanów się chwilę...
Zablokowłeś tabelę dla zapisu i pytasz się jak usunąć rekordy? (IMG:http://forum.php.pl/style_emoticons/default/withstupidsmiley.gif)

Edit:
Pomyliłem blokadę READ z WRITE (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Ten post edytował markac 30.08.2005, 10:43:55
Go to the top of the page
+Quote Post
sobstel
post
Post #3





Grupa: Zarejestrowani
Postów: 853
Pomógł: 25
Dołączył: 27.08.2003
Skąd: Katowice

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


Cytat(markac @ 2005-08-03 21:35:47)
Zastanów się chwilę...
Zablokowłeś tabelę dla zapisu i pytasz się jak usunąć rekordy?  (IMG:http://forum.php.pl/style_emoticons/default/withstupidsmiley.gif)

w takim razie dlaczego DELETE FROM table dziala? zablokowanie do zapisu to nie tylko zablokowanie do wykonywania INSERT i UPDATE
Go to the top of the page
+Quote Post
markac
post
Post #4





Grupa: Zarejestrowani
Postów: 83
Pomógł: 0
Dołączył: 23.02.2005

Ostrzeżenie: (10%)
X----


Cytat
TRUNCATE TABLE differs from DELETE FROM ... in the following ways:

Truncate operations drop and re-create the table, which is much faster than deleting rows one by one.
Not transaction-safe; you will get an error if you have an active transaction or an active table lock.
Doesn't return the number of deleted rows.
As long as the table definition file `table_name.frm' is valid, the table can be re-created this way, even if the data or index files have become corrupted.


Mam nadzieję, że to trochę rozjaśniło sytuację (IMG:http://forum.php.pl/style_emoticons/default/cool.gif)
Go to the top of the page
+Quote Post
sobstel
post
Post #5





Grupa: Zarejestrowani
Postów: 853
Pomógł: 25
Dołączył: 27.08.2003
Skąd: Katowice

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


no rozjasnilo ;-) tylko tyrzeba bylo tak od razu ;-)
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: 23.08.2025 - 14:27