If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > set a table to be emty?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-01-04, 06:54
digital_storm digital_storm is offline
Registered User
 
Join Date: Dec 2003
Posts: 28
set a table to be emty?

Hello!

In my GUI for Mysql there is a command "emty" that delete all the rows in current table.

How do I express that in normal syntax?

I dont want to drop the table just delete all the rows.

Regards// D_S
Reply With Quote
  #2 (permalink)  
Old 03-01-04, 08:55
praveenpr praveenpr is offline
Registered User
 
Join Date: Jan 2004
Location: Singapore
Posts: 89
Re: set a table to be emty?

Quote:
Originally posted by digital_storm
Hello!

In my GUI for Mysql there is a command "emty" that delete all the rows in current table.

How do I express that in normal syntax?

I dont want to drop the table just delete all the rows.

Regards// D_S
TRUNCATE TABLE TableName
__________________
Thanks and Regards,

Praveen Pulikunnu
Reply With Quote
  #3 (permalink)  
Old 04-01-04, 16:11
cpaul_it cpaul_it is offline
Registered User
 
Join Date: Jul 2003
Posts: 8
Re: set a table to be emty?

You may also simply do the following:

DELETE FROM [tablename];
Reply With Quote
  #4 (permalink)  
Old 04-02-04, 03:39
digital_storm digital_storm is offline
Registered User
 
Join Date: Dec 2003
Posts: 28
Hello,

If I do "DELETE" I will also delete the preferences of that table or?

Regards // D_S
Reply With Quote
  #5 (permalink)  
Old 04-02-04, 07:21
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
praveenpr, in mysql truncate actually drops and recreates the table

this is very fast but there is a drop involved, which d_s didn't want, for reasons which are not yet clear

d_s, what do you mean by "preferences"?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 04-02-04, 07:51
digital_storm digital_storm is offline
Registered User
 
Join Date: Dec 2003
Posts: 28
Hello,

For example "Alter Table"
Reply With Quote
  #7 (permalink)  
Old 04-02-04, 08:00
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
DS, you still aren't clear. Do you mean you have used Alter Table on this particular table and are worried you will lose any changes you have made? Or do you mean if you run the delete you won't be able to use Alter table in the future?

If you use

DELETE from tablename;

you will delete all the table data, but the schema will still be there for the table itself. You won't change the table in any way other than dropping what is contained in it. You will still be able to alter the table in the future to add new columns etc.
Reply With Quote
  #8 (permalink)  
Old 04-02-04, 09:33
digital_storm digital_storm is offline
Registered User
 
Join Date: Dec 2003
Posts: 28
Hello,

You have to excuse me.... I will explain.
I have a table called TEMP which I store temporary data, this table is "ALTERED BY" "playnr".

When I have used my temporary data I want to delete all data in my table "TEMP" but next time data is stored it will be altered by "playnr" again


Regards// D_S
Reply With Quote
  #9 (permalink)  
Old 04-02-04, 09:58
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
your last description is very confusing

first of all, if the table hangs around, it isn't really temporary, is it

second, what does altered by "playnr" again mean?

what exactly is being altered? are you adding a "playnr" column that wasn't there before?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #10 (permalink)  
Old 04-02-04, 12:26
digital_storm digital_storm is offline
Registered User
 
Join Date: Dec 2003
Posts: 28
Hello,

1) The table is static...the information in that table are used once and then I want to set my table as empty.
2) I have predefined colums and...
3) I have a column called "playnr" in my table TEMP (its my "primary key")

I hope this helps..

Thanks again! // D_S
Reply With Quote
  #11 (permalink)  
Old 04-02-04, 12:35
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
aha, the primary key

no, you'll be fine

TRUNCATE resets auto_increments, but leaves constraints on the table
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #12 (permalink)  
Old 04-02-04, 14:00
digital_storm digital_storm is offline
Registered User
 
Join Date: Dec 2003
Posts: 28
Hello,

Ok....

Thank you for your help!

Regards // D_S
Reply With Quote
  #13 (permalink)  
Old 04-02-04, 14:43
Avatar Avatar is offline
Registered User
 
Join Date: Oct 2003
Location: Buenos Aires, Argentina
Posts: 20
Yes..
you must use the "TRUNCATE TableName" query.
I'll delete all the data, reset the autoincrements but the structure will be the same.

__________________
------------------------------------
Thanx
------------------------------------
http://www.iespana.es/greatavatar/FIRMA/firma.jpg
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On