user14509722
user14509722

Reputation:

SQL showing an error when creating table with columns that have the data type longtext

So im makign a framework that has the option to cache and store files, now one of the cache sources is xe_templates for theme templates, my query looks like this

CREATE TABLE `test` (
    name LONGTEXT(4294967295),
    lastedit LONGTEXT(4294967295),
    data LONGTEXT(4294967295),
    type LONGTEXT(4294967295),
    lastEdit LONGTEXT(4294967295)
);

the error I get is this


#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(4294967295),
    lastedit LONGTEXT(4294967295),
    data LONGTEXT(42949672...' at line 2


Upvotes: 1

Views: 364

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269563

VARCHAR() takes a length, but the text types do not. So just use:

CREATE TABLE `test` (
    name LONGTEXT,
    lastedit LONGTEXT,
    data LONGTEXT,
    type LONGTEXT,
    lastEdit2 LONGTEXT
);

That said, LONGTEXT should be used sparingly. I have trouble imagining a name that is going to be measured in the Mbytes or Gbytes.

I changed the name of the last column to lastEdit2 because two columns cannot have the same name in a table.

Upvotes: 1

Related Questions