Solved

dropping database tables without dropping database or finding all the table names

Posted on 2013-01-21
7
291 Views
Last Modified: 2013-01-23
delete all the tables from a database
many tables, do not want to copy and paste many times





I can not just drop the database and create database
because I am using shared hosting
0
Comment
Question by:rgb192
7 Comments
 
LVL 2

Expert Comment

by:davemj9876
ID: 38803969
What level of access do you have to the database.  Command line, only through something like php etc?  The answer will depend on what access you have
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 38804063
I think you need like this simple mysql management tool (not like phpMyAdmin) .. download this ,  configure and upload in your shared hosting,
http://sqlbuddy.com/

so you can easily access Db tables, change, alter all are possible.
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 38804065
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:rgb192
ID: 38804155
i am using mysql workbench query tool

because I have shared hosting, I can not create a database
I can do many operations (delete database, create/delete table)
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 38804163
If you have using shared hosting, it might be limited to create db. just ask them for more details.

also, you can get phpMyAdmin access on browser itself.
0
 
LVL 7

Accepted Solution

by:
aplusexpert earned 500 total points
ID: 38805082
Try this script. this may help you

DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR

SET @Cursor = CURSOR FAST_FORWARD FOR

SELECT DISTINCT sql = 'ALTER TABLE [' + tc2.TABLE_NAME + '] DROP [' + rc1.CONSTRAINT_NAME + ']'

FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1

LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME

OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql

WHILE (@@FETCH_STATUS = 0)

BEGIN

Exec SP_EXECUTESQL @Sql

FETCH NEXT FROM @Cursor INTO @Sql

END

CLOSE @Cursor DEALLOCATE @Cursor

GO

EXEC sp_MSForEachTable 'DROP TABLE ?'

GO

Open in new window


OR

EXEC sp_msforeachtable 'DROP TABLE ?'

Open in new window


Thanks
0
 

Author Closing Comment

by:rgb192
ID: 38813087
thanks for db script
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question