![]() |
Empty a DB?
Is there a way to empty a DB without having direct access (ie phpMyAdmin)? I searched the MySQL reference documentation and couldn't find (or maybe I missed it?) what I was looking for.
|
The best method, IMHO, is to use TRUNCATE (similar to DELETE on all records, but resets the table as well).
I don't know what you mean by 'direct access'. If you don't have 'direct access' one way or another (PHP script, phpMyAdmin, mysql command line client) then how else would you perform a query? |
I think he means via a query and not the MySQL application via command line. If I'm right then SOCK is right with
TRUNCATE :-) ! |
Ok, well as long as the connecting user has DELETE permissions, TRUNCATE will work from a PHP script.
MySQL Manual : TRUNCATE |
I don't want to empty all of the existing tables, I want to get rid of every existing table in the database.
Thanks for replies. |
How many tables do you have? You could just use DROP TABLE (MySQL :: MySQL 5.1 Reference Manual :: 12.1.16 DROP TABLE Syntax) on each one.
PHP Code:
Alan |
Quote:
Quote:
You can use the command line tool 'mysqladmin' to drop all tables in a comma delimited list, I believe. If you could create a system exec() statement that called this function with those parameters it might be easier to do that several calls to mysql_query() to drop the table(s) (depending on how many you have). The other way to look at it, if you have the privilege to do so, just make one call to Code:
DROP DATABASE databasename; |
aye, sorry for the confusion, sock. I'm pretty sure I dont have the perms to be able to drop/delete an entire database.
Alan- that answers my question to a degree, but- the problem, and my fault for not bringing this up in my original post, is that I don't know all of the table names/prefixes in the db. So, is it possible to drop all tables in the DB with something along the lines of this: Quote:
Quote:
Thanks for help so far! |
Just DROP the database. If you don't have permissions, get them.
|
| All times are GMT. The time now is 12:41 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0