Is there SQL syntax or php coding to drop all tables in a database
There maybe a range of different tables so I cant name them all as sometimes they may not be there but can I just drop all tables in a database and if so how???
@96turnerriNov 11.2004 — #well the SYNTAX for DROP is [code=php]DROP TABLE table_name[/code] and since [code=php]SELECT * FROM[/code] is the same as [code=php]SELECT colomn1, the rest in here lastcolomn FROM[/code]
so instead of [code=php]DROP TABLE first_table, the rest in here last_table[/code] you could use [code=php]DROP TABLE *[/code] would work, however that is untested
@96turnerriNov 11.2004 — #thats why i suggest SHOW TABLES and THEN for EACH drop or build the query using SHOW TABLES then its only executing one SQL command
@KeveenNov 12.2004 — #I have had the same problem, trying to drop all hte tables in a database while testing and transferring web sites to different servers. I could not find a command, it seems to be one of those obvious common sense requirements that somehow got left out of the command programming. I'm not a programmer so most of the time I'm using one of the front ends and MySQL 4 thankfully has an option to select all tables after which you select the command DROP and the database is emptied, ready to import a new or backed up sql backup file. Can't imagine life without some kind of graphic front end!
Anyting like usik's statement yields:Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM nightshift58 at line 1