How to set a varchar to have unlimited length?

前端 未结 5 695
一整个雨季
一整个雨季 2021-02-01 15:10

In a MySQL database, how would I set a varchar to have unlimited length, so that I can store long web pages? IF not , then what is the Maximum Size?

I know about Text Ty

5条回答
  •  一向
    一向 (楼主)
    2021-02-01 15:58

    To answer the other part of his question ...

    Are there any limitations which i have to handle?

    There can be all sorts of unforeseen limits depending on versions of software, data storage engine, etc.

    I encountered these.

    ALTER TABLE reportserver.report ADD reportquery varchar(65535)
    

    Error Code: 1074. Column length too big for column 'reportquery' (max = 21845); use BLOB or TEXT instead

    ALTER TABLE reportserver.report ADD reportquery varchar(21845)
    

    Error Code: 1118. Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs

    You'd probably encounter these when setting up your table or not at all, but rather than risk not being able to add more columns, or not being able to make a column wider, you might want to go the TEXT route straight away if you have seriously wide columns.

提交回复
热议问题