I have to remove all sights from the mysql database. How do i do this using query.
Anyone might help me plz.
do this untested code
DECLARE VIEW_NAME VARCHAR(31); DECLARE VIEW_NAMES CURSOR FOR SELECT table_name FROM information_schema.views; WHERE table_schema = 'DB_Name' OPEN VIEW_NAMES; REPEAT FETCH VIEW_NAMES INTO VIEW_NAME; DROP VIEW VIEW_NAME UNTIL done END REPEAT; CLOSE VIEW_NAMES; END;
Estimating from MySQL Reference Manual (http://dev.mysql.com/doc/refman/5.6/en/drop-view.html):
DROP VIEW [IF EXISTS] view_name [, view_name] ... [RESTRICT | CASCADE]
DROP VIEW removes a number of sights. You'll want the DROP privilege for every view. If the sights named within the argument list don't exist, MySQL returns a mistake showing by title which non-existing sights it had been not able to decrease, it drops all the sights within the list which do exist.
The IF Is available clause prevents a mistake from occurring for sights that do not exist. If this clause is offered, an email is produced for every nonexistent view. See Section 220.127.116.11, “SHOW Alerts Syntax”.
RESTRICT and CASCADE, if given, are parsed and overlooked