What's the difference between VARCHAR(255) and TINYTEXT string types in MySQL?

后端 未结 3 1297
再見小時候
再見小時候 2020-12-04 23:39

What\'s the difference between VARCHAR(255) and TINYTEXT string types in MySQL?

Each of them allows to store strings with a maximum length of 255 characters. Storage

相关标签:
3条回答
  • 2020-12-05 00:18

    Using VARCHAR you can set the column to NULL or NOT NULL and you can set DEFAULT value, but not with TEXT. Use VARCHAR if you need one or both feature, NULL and DEFAULT.

    0 讨论(0)
  • 2020-12-05 00:22

    You cannot assign a DEFAULT value to a TINYTEXT and you cannot create an unprefixed index on the latter.

    Internally, additional objects are allocated in memory to handle TEXT (incl. TINYTEXT) columns which can cause memory fragmentation on the large recordsets.

    Note that this only concerns the column's internal representation in the recordsets, not how they are stored on the disk.

    0 讨论(0)
  • 2020-12-05 00:30

    in varchar you have to set the length of a character whereas in tanytext there is nothing like this it saves the memory of data base for ex:

    for address you have to define the varchar(50) than your address may be 50 charecter or less the worse condition is your character more than the 50 character this is the limitation of varchar if character is less than 50 than it occupy the 50 character memory in this case memory is increases

    so use tanytext it define the character length depend upon the size of character so memory is saved

    0 讨论(0)
提交回复
热议问题