Solved

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

Posted on 2013-01-21
7
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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