[英]What's wrong with my MySQL code here in varchar(max) line?
create table snippet(
id int not null auto_increment,
primary key(id),
idlanguage int not null,
foreign key(idlanguage) references language(id),
iduser int not null,
foreign key(iduser) references user(id),
title varchar(200) not null,
content varchar(max) not null,
rating int,
creationdate datetime
);
I'm getting an error at line 9 near 'max)' according to PHPMyAdmin. 根据PHPMyAdmin,我在第9行的“ max)附近出现错误”。
VARCHAR(MAX)
is an MS SQL Server extension to the SQL language -- it does not exist in mysql. VARCHAR(MAX)
是SQL语言的MS SQL Server扩展-mysql中不存在。 Put a number there and you will be golden. 在那放一个数字,你会很高兴。
I don't think that " max
" is a valid value for the maximum number of character that can be put in your content
column : you should specify a numerical value. 我认为“ max
”不是可以在content
列中输入的最大字符数的有效值:您应该指定一个数字值。
But note that varchar
has a limited maximum length (see the varchar
page in the MYSQL's manual for the details) -- which means it might not be the best data-type for a " content
" column. 但是请注意, varchar
的最大长度是有限的(有关详细信息,请参见MYSQL手册中的varchar
页 ) -这意味着它对于“ content
”列可能不是最佳的数据类型。
A possibibly better solution might be to use one of the TEXT
data-type : 可能更好的解决方案是使用TEXT
数据类型之一:
...
content TEXT not null,
...
TEXT
columns can contain strings that are a lot longer than varchar ; TEXT
列可以包含比varchar长得多的字符串; for more informations, see 10.4.3. 有关更多信息,请参见10.4.3。 The BLOB and TEXT Types . BLOB和TEXT类型 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.