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.
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.
As documented under Schema Object Names:
Before MySQL 5.1.6, database and table names cannot contain “
/
”, “\
”, “.
”, or characters that are not permitted in file names.
Incidentally, had you wanted to create a table called info
within a database called account
, then note that as documented under Identifier Qualifiers:
If any components of a multiple-part name require quoting, quote them individually rather than quoting the name as a whole. For example, write
`my-table`.`my-column`
, not`my-table.my-column`
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With