By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

How to delete a MySQL database table without system()

P: n/a
I want to delete a MySQL table without using functions of the OS, so
that my php script can run on any webserver. Can I use a command like

$sql = "DELETE FROM tablename";

or are there better ways to do the job?

Thanks for answers, Hartmut

Aug 7 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Hartmut Jaeger" <ha************@jaeger-edv-service.de> kirjoitti
viestissä:11**********************@g14g2000cwa.goo glegroups.com...
I want to delete a MySQL table without using functions of the OS, so
that my php script can run on any webserver. Can I use a command like

$sql = "DELETE FROM tablename";

or are there better ways to do the job?

Thanks for answers, Hartmut

DROP <name of table>

http://mysqld.active-venture.com/DROP_TABLE.html

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <et****************@5P4Mgmail.com>
Aug 7 '05 #2

P: n/a
But DROP deletes the complete table and the index and all structures. I
want to keep an empty table with all the structures, which I can fill
with data again.

Aug 8 '05 #3

P: n/a
On 2005-08-08 13-41-45 Hartmut Jaeger
<ha************@jaeger-edv-service.de> wrote:
But DROP deletes the complete table and the index and all structures. I
want to keep an empty table with all the structures, which I can fill
with data again.


TRUNCATE <tablename>;

HTH,
Simon
--
Simon Stienen <http://slashlife.org/>
"What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done."
/Sherlock Holmes in A Study in Scarlet by Sir Arthur Conan Doyle/
Aug 8 '05 #4

P: n/a
Thanks, this command is the solution I searched for. Seems, that I am
unable to read manuals ;-). But the command needs the keyword TABLE:

TRUNCATE TABLE <tablename>

Hartmut

Aug 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.