这个mysql建表查询有什么问题?
我的生产服务器中有一个数据库,它工作正常...我所做的是转储该数据库并在本地系统中执行。除了一个表之外,所有其他表都已创建...所以我手动插入它,
CREATE TABLE `contact` (
`contactId` int(11) NOT NULL AUTO_INCREMENT,
`cRefId` int(20) DEFAULT '0',
`contactFirstName` varchar(100) DEFAULT NULL,
`contactLastName` varchar(100) DEFAULT NULL,
`contactPhone` varchar(35) DEFAULT NULL,
`contactEmail` varchar(150) DEFAULT NULL,
`organizationid` int(11) NOT NULL,
`mobileNo` varchar(35) DEFAULT NULL,
`dor` datetime DEFAULT NULL,
`doe` datetime DEFAULT NULL,
`dod` datetime DEFAULT NULL,
`designation` varchar(50) DEFAULT NULL,
`income` double DEFAULT NULL,
`homeloan` tinyint(1) DEFAULT NULL,
`companyName` varchar(200) DEFAULT NULL,
`isDeleted` tinyint(1) DEFAULT '0',
`addressId` int(11) DEFAULT NULL,
`accgroupid` int(11) DEFAULT NULL,
`createdBy` int(11) DEFAULT NULL,
`editedBy` int(11) DEFAULT NULL,
`deletedBy` int(11) DEFAULT NULL,
`assignedto` int(11) DEFAULT NULL,
`industryid` int(11) DEFAULT NULL,
`note` varchar(150) DEFAULT NULL,
`twirrerId` varchar(150) DEFAULT NULL,
`linkedinId` varchar(150) DEFAULT NULL,
PRIMARY KEY (`contactId`),
KEY `aa` (`organizationid`),
KEY `add_id` (`addressId`),
KEY `idx_contactid` (`contactId`),
KEY `FK_contact` (`industryid`),
KEY `fk_contacteditedby_user` (`editedBy`),
KEY `fk_contactaccount_account` (`accgroupid`,`contactId`),
KEY `contact_First_Name` (`contactFirstName`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
但是当我执行这个时,我收到以下错误,
Error Code : 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax
to use near 'USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1' at line 35
I have a database in my production server and it works fine... What i did is took a dump of that DB and executed in my local system.. All the other tables are created except one table... So i manually inserted it,
CREATE TABLE `contact` (
`contactId` int(11) NOT NULL AUTO_INCREMENT,
`cRefId` int(20) DEFAULT '0',
`contactFirstName` varchar(100) DEFAULT NULL,
`contactLastName` varchar(100) DEFAULT NULL,
`contactPhone` varchar(35) DEFAULT NULL,
`contactEmail` varchar(150) DEFAULT NULL,
`organizationid` int(11) NOT NULL,
`mobileNo` varchar(35) DEFAULT NULL,
`dor` datetime DEFAULT NULL,
`doe` datetime DEFAULT NULL,
`dod` datetime DEFAULT NULL,
`designation` varchar(50) DEFAULT NULL,
`income` double DEFAULT NULL,
`homeloan` tinyint(1) DEFAULT NULL,
`companyName` varchar(200) DEFAULT NULL,
`isDeleted` tinyint(1) DEFAULT '0',
`addressId` int(11) DEFAULT NULL,
`accgroupid` int(11) DEFAULT NULL,
`createdBy` int(11) DEFAULT NULL,
`editedBy` int(11) DEFAULT NULL,
`deletedBy` int(11) DEFAULT NULL,
`assignedto` int(11) DEFAULT NULL,
`industryid` int(11) DEFAULT NULL,
`note` varchar(150) DEFAULT NULL,
`twirrerId` varchar(150) DEFAULT NULL,
`linkedinId` varchar(150) DEFAULT NULL,
PRIMARY KEY (`contactId`),
KEY `aa` (`organizationid`),
KEY `add_id` (`addressId`),
KEY `idx_contactid` (`contactId`),
KEY `FK_contact` (`industryid`),
KEY `fk_contacteditedby_user` (`editedBy`),
KEY `fk_contactaccount_account` (`accgroupid`,`contactId`),
KEY `contact_First_Name` (`contactFirstName`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
But when i execute this i get the following error,
Error Code : 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax
to use near 'USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1' at line 35
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我非常确定您必须指定
using
在您正在使用的索引列之前:该链接中引用的 doco 状态 (MySQL 5.1):
并且
[index_type]
是使用 btree
位。如果失败,请检查源服务器和目标服务器上是否有兼容的版本。有一个补丁可以使该命令的解释在命令的顺序方面更加稳健。
或者您可以完全删除
using btree
并使用服务器默认方法,尽管您应该理解在选择它作为选项之前先了解其后果。I'm pretty certain you have to specify the
using
before the index column that you're using:The doco referenced in that link states (MySQL 5.1):
and
[index_type]
is theusing btree
bit.Failing that, check that you have compatible versions on the source and destination server. There was a patch which made the interpretation of that command a little more robust in terms of what order they should be in.
Or you could remove the
using btree
altogether and use the server default method though you should understand the ramifications of that before choosing it as an option.您应该在开发和生产系统中使用相同版本的 mysql(当然,测试 mysql 升级时除外)。
使用不同的版本会使测试无效。不要这样做。您的开发系统应该运行与您在生产中使用的完全相同的服务器构建,唯一应该不同的是为了使其正常工作所需的参数(假设您在生产中拥有 32G 内存,但您的系统上只有 4G)测试服务器,您需要缩小那里的缓冲区)
You should use the same version of mysql in your development and production systems (except when testing a mysql upgrade, of course).
Using a different version invalidates testing. Don't do it. Your development system should run the exact same server build as you use in production, the only things which should be different are parameters which need to be in order for it to work (say you have 32G of ram in production, but only 4G on your test server, you need to make the buffers smaller there)
您确定您使用的 MySQL 版本支持“USING BTREE”吗?如果我没记错的话,这是 MySQL 5.1 的一个特性。
您也可以点击 http://bugs.mysql.com/bug.php?id =25162
编辑:实际上,这只是 MySQL 5 的一个功能。
Are you sure you are using a version of MySQL where 'USING BTREE' is supported? If I recall correctly, that's a MySQL 5.1 feature.
You could also have hit http://bugs.mysql.com/bug.php?id=25162
Edit: Actually, it's just a MySQL 5 feature.