[英]Google Cloud SQL Datatypes
I just have a quick query. 我只是快速查询一下。 I am trying to create a database table (I have a cloud sql database using Google Cloud) I can create databases, tables and insert into them fine.
我正在尝试创建数据库表(我有使用Google Cloud的cloud sql数据库),我可以创建数据库,表并将其插入其中。 But I am having trouble with one field.
但是我在一个领域遇到麻烦。 Do you know if there is mysql character type for date and/or time?
您是否知道日期和/或时间的mysql字符类型?
I am using the following query but the character types DATE, DATETIME AND TIMESTAMP will not work and the query is not successful: 我正在使用以下查询,但是字符类型DATE,DATETIME和TIMESTAMP将不起作用,并且查询不成功:
CREATE TABLE entries (id INT(30) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstName VARCHAR(30), surname VARCHAR(30), course VARCHAR(50), subject VARCHAR(50), level VARCHAR(50), checkIn DATETIME(50));
When I submit that I get the following error (which corresponds to the DATETIME character type, not the checkIn field name but the DATETIME character type): 当我提交时,出现以下错误(对应于DATETIME字符类型,而不是checkIn字段名称,而是DATETIME字符类型):
ERROR 1064 (42000): 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 '(50))
So basically do you know if there is a date or time character type for mysql that can be used in the cloud (with Google)? 因此,基本上,您是否知道可以在云中使用mysql的日期或时间字符类型(与Google一起使用)?
There is no size parameter for DATETIME, or any other date /time data type and that is your error. DATETIME或任何其他日期/时间数据类型没有大小参数,这是您的错误。 Just specify DATETIME.
只需指定DATETIME。
I think the syntax error you are getting is bcoz of big precision limit of DATETIME
. 我认为您遇到的语法错误是
DATETIME
的大精度限制的bcoz。 So, try this: 因此,请尝试以下操作:
CREATE TABLE entries (id INT(30) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstName VARCHAR(30),
surname VARCHAR(30),
course VARCHAR(50),
subject VARCHAR(50),
level VARCHAR(50),
checkIn DATETIME);
And the maximum precision limit for DATETIME
in Mysql
is 6 ie, DATETIME(6)
Mysql
DATETIME
的最大精度限制为6,即DATETIME(6)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.