| |
|
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.
|
 |

03-01-04, 06:54
|
|
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
|
|

03-01-04, 08:55
|
|
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
|
|

04-01-04, 16:11
|
|
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];
|
|

04-02-04, 03:39
|
|
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
|
|

04-02-04, 07:21
|
|
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"?
|
|

04-02-04, 07:51
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 28
|
|
Hello,
For example "Alter Table"
|
|

04-02-04, 08:00
|
|
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.
|
|

04-02-04, 09:33
|
|
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
|
|

04-02-04, 09:58
|
|
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?
|
|

04-02-04, 12:26
|
|
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
|
|

04-02-04, 12:35
|
|
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
|
|

04-02-04, 14:00
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 28
|
|
Hello,
Ok....
Thank you for your help!
Regards // D_S
|
|

04-02-04, 14:43
|
|
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.

|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|