Mihai-Ion Stefan
Mihai-Ion Stefan

Reputation: 1

Found a SQL error and I don't know what to do

I am just a beginner who need a little help with this SQL syntax error. Thank you!

Code:

use influencersv2;
CREATE TABLE Articles (
  Articles_Id int auto_increment not null,
  Articles_Authors_Id int not null,
  Articles_Tag_Id int not null,
  Articles_Date DateTime not null,
  Articles_Title varchar(250) not null,
  Articles_Content mediumtext not null,
  Articles_Image varbinary(max) null,
  Articles_Edit BIT  not null,
  Articles_Votes int not null,
);

Error :

SQL Error [1064] [42000]: 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 'max) null,
  Articles_Edit BIT  not null,
  Articles_Votes int not null...' at line 8

Upvotes: 0

Views: 68

Answers (1)

PMichaletzky
PMichaletzky

Reputation: 11

The maximum allowed rowsize is 65535 bytes, including all your columns, unless you use BLOB or TEXT as one of your column types. Since you already have a couple of columns and a rather big 250 wide Varchar, they all reduce the maximum remaining space for your Varbinary. What practically remains for your Varbinary is 65248 bytes.

This works:

CREATE or replace TABLE Articles (
  Articles_Id int auto_increment not null,
  Articles_Authors_Id int not null,
  Articles_Tag_Id int not null,
  Articles_Date DateTime not null,
  Articles_Title varchar(250) not null,
  Articles_Content mediumtext not null,
  Articles_Image VARBINARY(65248) null,
  Articles_Edit BIT  not null,
  Articles_Votes int not NULL,
  PRIMARY KEY (Articles_Id)
);

MariaDB will not find out this value for you automatically.

Upvotes: 1

Related Questions