Drop Table if exists statement giving error

database, mysql, sql

Solution

From http://dev.mysql.com/doc/refman/5.1/en/identifiers.html: "Before MySQL 5.1.6, database and table names cannot contain “/”, “\”, “.”, or characters that are not permitted in file names."

Which is why I gave this answer:

You can't use dots in table names. Dots are used to separate database names and table names (and column names). You could try using ``account`.`info`` if your database name is `account` and the table name is `info`. If the table name is supposed to be `account.info`, you should change that to something else, like `account_info`. I don't agree with some of the other answers: Quoting never hurts, if done properly.

Since 5.1.6 you can use whatever you please, as shown by @eggyal and others.

Problem

I have following block of code in MySql: ``` DROP TABLE IF EXISTS `account.info`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `account.info` ( `id` int(11) NOT NULL AUTO_INCREMENT, `account_id` int(11) NOT NULL, `year_id` int(11) NOT NULL, `school_id` int(11) NOT NULL, PRIMARY KEY (`id`,`account_id`,`year_id`,`school_id`) ) ENGINE=InnoDB AUTO_INCREMENT=7177 DEFAULT CHARSET=utf8; ``` Its giving me error on first line as: ``` ERROR 1103 (42000) at line 56: Incorrect table name 'account.info' ``` What is wrong in it? Please help me.

Original source

Related problems