Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
280 views
in Technique[技术] by (71.8m points)

Row size too large error in mysql create table query

I am trying to create a table with the below query

Create Table PerformaceReport
(
campaignID int,
keywordID bigint,
keyword varchar(8000),
avgPosition decimal(18,6),
cost int,
clicks int,
 conv1PerClick int, 
 impressions int,
  day datetime,
  currency varchar(8000),
  account varchar(8000),
   timeZone varchar(8000),
    adGroup varchar(8000),
    adGroupState varchar(8000),
     approvalStatus varchar(8000),
     lowestPosition varchar(8000),
     campaign varchar(8000),
      campaignState varchar(8000),
       convManyPerClick int,
       totalConvValue decimal(18,6),
        maxCPCSource varchar(8000),
         clientName varchar(8000),
          destinationURL varchar(8000),
           device varchar(8000),
           firstPageCPC int,
            isNegative bit,
             matchType varchar(8000),
              maxCPC varchar(8000),
               maxCPM varchar(8000),
               highestPosition varchar(8000),
               qualityScore int,
               keywordState varchar(8000),
               viewThroughConv int)

And i am getting the below error

#1118 - Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs

Can anyone please let me know how to avoid this error and make the query work to create a table.

question from:https://stackoverflow.com/questions/13283381/row-size-too-large-error-in-mysql-create-table-query

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The total size of all fields in the table is more than the limit, 65535, that's why you are getting this error.

You should use text type instead of varchar for long strings. Replace all varchar(8000) with text, and it should work.

Or, even better, use appropriate data types instead of the "too large" ones. You don't really need 8000 characters to store currency, do you?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...