MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old June 29th, 2000, 08:10 AM
TSRealm TSRealm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Randolph, NJ
Posts: 36 TSRealm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to TSRealm
I want to keep my table in my database, but I want to delete all entries because they were just tests. How would I be able to delete the entries, and not the whole table. Thank you in advance.

------------------
================
-Khill, www.tsrealm.com

Reply With Quote
  #2  
Old June 29th, 2000, 11:56 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
> delete from table_name;

You can't remove a table in the client app by using "delete" so you can monkey around with it without worrying about removing your actual table...you'd have to use "drop table table_name" to remove the whole table

Reply With Quote
  #3  
Old June 29th, 2000, 06:42 PM
jcbell jcbell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 14 jcbell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Go to http://www.mysql.com/Manual_chapter...?section=DELETE

which reads:

DELETE [LOW_PRIORITY] FROM tbl_name
[WHERE where_definition] [LIMIT rows]


DELETE deletes rows from tbl_name that satisfy the condition given by where_definition, and returns the number of
records deleted.

If you issue a DELETE with no WHERE clause, all rows are deleted. MySQL does this by recreating the table as an empty table,
which is much faster than deleting each row. In this case, DELETE returns zero as the number of affected records. (MySQL can't
return the number of rows that were actually deleted, because the recreate is done without opening the data files. As long as the
table definition file `tbl_name.frm' is valid, the table can be recreated this way, even if the data or index files have become
corrupted.).

If you really want to know how many records are deleted when you are deleting all rows, and are willing to suffer a speed penalty,
you can use a DELETE statement of this form:

mysql> DELETE FROM tbl_name WHERE 1>0;

Note that this is MUCH slower than DELETE FROM tbl_name with no WHERE clause, because it deletes rows one at a time.

If you specify the keyword LOW_PRIORITY, execution of the DELETE is delayed until no other clients are reading from the table.

Deleted records are maintained in a linked list and subsequent INSERT operations reuse old record positions. To reclaim unused
space and reduce file sizes, use the OPTIMIZE TABLE statement or the myisamchk utility to reorganize tables. OPTIMIZE
TABLE is easier, but myisamchk is faster. See section 7.10 OPTIMIZE TABLE syntax, and section 15.4.3 Table optimization.

The MySQL-specific LIMIT rows option to DELETE tells the server the maximum number of rows to be deleted before control
is returned to the client. This can be used to ensure that a specific DELETE command doesn't take too much time. You can simply
repeat the DELETE command until the number of affected rows is less than the LIMIT value.


Reply With Quote
  #4  
Old June 29th, 2000, 07:03 PM
TSRealm TSRealm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Randolph, NJ
Posts: 36 TSRealm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to TSRealm
Thanks a lot guys. I deleted the whole table because it was all a test. But now I know I can delete specific rows in case some idiot posts something stupid. Thanks.

------------------
================
-Khill, www.tsrealm.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Deleting Info


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway