这个mysql建表查询有什么问题?

发布于 2024-09-09 09:05:48 字数 1808 浏览 9 评论 0原文

我的生产服务器中有一个数据库,它工作正常...我所做的是转储该数据库并在本地系统中执行。除了一个表之外,所有其他表都已创建...所以我手动插入它,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

泅人 2024-09-16 09:05:48

我非常确定您必须指定 using 您正在使用的索引列之前:

... KEY `contact_First_Name` USING BTREE (`contactFirstName`)

该链接中引用的 doco 状态 (MySQL 5.1):

{INDEX|KEY} [index_name] [index_type] (index_col_name,...) [index_option] ...

并且 [index_type]使用 btree 位。

如果失败,请检查源服务器和目标服务器上是否有兼容的版本。有一个补丁可以使该命令的解释在命令的顺序方面更加稳健。

或者您可以完全删除 using btree 并使用服务器默认方法,尽管您应该理解在选择它作为选项之前先了解其后果。

I'm pretty certain you have to specify the using before the index column that you're using:

... KEY `contact_First_Name` USING BTREE (`contactFirstName`)

The doco referenced in that link states (MySQL 5.1):

{INDEX|KEY} [index_name] [index_type] (index_col_name,...) [index_option] ...

and [index_type] is the using 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.

回忆凄美了谁 2024-09-16 09:05:48

您应该在开发和生产系统中使用相同版本的 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)

送君千里 2024-09-16 09:05:48

您确定您使用的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文