0

how can i delete the current database?

DROP DATABASE()

ERROR 1064 (42000): You have an error in your SQL syntax

this is the error that i get

1

3 Answers 3

1

You can use DROP DATABASE dbname syntax.

Source

Sign up to request clarification or add additional context in comments.

2 Comments

yes i know but how can i do it when i dont know the name?
You mean what? Dynamically dropping or without knowing anything ? If you mean second that is not possible. You have to indicate dbname.
1
SET @q = CONCAT('DROP DATABASE ', DATABASE(), ';');
PREPARE stmt FROM @q;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

All precautions that apply to any statement involving a DROP, and especially a DROP DATABASE, apply here too, and then some.

Comments

0

This is the syntax:

DROP DATABASE databasename;

1 Comment

yes i know but how can i do it when i dont know the name?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.