我正在尝试将数据库从 mysql 移植到 infinidb。但是我在移植时遇到了错误(在标题中描述)。
`CREATE_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
在 mysql 中有效,但在 infinidb 中无效。错误是:错误代码:138。infinidb 不支持语法或数据类型。任何帮助将不胜感激。
我正在尝试将数据库从 mysql 移植到 infinidb。但是我在移植时遇到了错误(在标题中描述)。
`CREATE_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
在 mysql 中有效,但在 infinidb 中无效。错误是:错误代码:138。infinidb 不支持语法或数据类型。任何帮助将不胜感激。
看起来您不能在 InfiniDB 中使用时间戳数据类型。我的版本与@mhoglan 相同,但该查询似乎有一点错误:
mysql> create table test (`CREATE_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
Query OK, 0 rows affected (0.00 sec)
缺少“engine=infinidb;” 最后,这将在 infinidb 中创建表。相反,该表是使用 MySQL 的默认引擎(MyISAM 或其他)创建的。
mysql> create table test (`CREATE_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) engine=infinidb;
ERROR 138 (HY000): The syntax or the data type(s) is not supported by InfiniDB. Please check the InfiniDB syntax guide for supported syntax or data types.
如您所见,添加 engine=infinidb 失败。
如果您可以使用 datetime 代替,那可能是要走的路;现在似乎不支持时间戳:(
这是您尝试的完整 SQL 语句吗?我能够使用:
create table test (`CREATE_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
这是控制台输出
[root@centos6 bin]# idbmysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.1.73 Calpont InfiniDB 4.5 Alpha
Copyright (c) 2014, InfiniDB, Inc. and/or its affiliates. All rights reserved.
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
InfiniDB is a registered trademark of InfiniDB, Inc. and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test;
Database changed
mysql> create table test (`CREATE_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
Query OK, 0 rows affected (0.00 sec)
mysql> describe test;
+------------------+-----------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+-----------+------+-----+-------------------+-----------------------------+
| CREATE_TIMESTAMP | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+------------------+-----------+------+-----+-------------------+-----------------------------+
1 row in set (0.00 sec)
mysql>
让我知道这是否不起作用或者您以不同的方式尝试语法。还有你在尝试什么版本的 InfiniDB?
谢谢!
我猜这是 InfiniDB 中不允许的 NOT NULL 约束。