What is the difference between Text and LongText in Laravel migration?
P粉268284930
P粉268284930 2023-11-08 16:42:35
0
2
690

The migration file sections are listed below:

Schema::create('samples', function (Blueprint $table) {
        $table->id();
        $table->text('title1');
        $table->longText('title2');
        $table->timestamps();
    });


P粉268284930
P粉268284930

reply all(2)
P粉523335026

This has nothing to do with Laravel migrations, but rather the data type of the table column, which depends on the size of the text string.

TINYTEXT: 255 characters - 255 B

TINYTEXT The data object is the smallest of the TEXT series and is designed to efficiently store short message strings. This type can store up to 255 bytes (expressed as 2^8 -1) or 255 characters and requires 1 byte of overhead. This object can be used to store things like short snippets, URL links, and other shorter objects. TINYTEXT is preferred over VARCHAR when storing data that is less than 255 characters long and is not of consistent length and does not need to be used for sorting criteria.

Text: 65,535 characters - 64 KB

The standard TEXT data object is sufficient to handle typical long-form text content. TEXT The maximum size of a data object is 64 KB (expressed as 2^16 -1) or 65,535 characters, requiring 2 bytes of overhead. It's large enough to hold text like an article, but not large enough to hold the text of an entire book.

MEDIUMTEXT: 16,777,215 characters - 16 MB

MEDIUMTEXT Data objects are useful for storing larger text strings such as white papers, books, and code backups. These data objects can be as large as 16 MB (expressed as 2^24 -1) or 16,777,215 characters, and require 3 bytes of overhead storage.

Long text: 4,294,967,295 characters - 4 GB

LONGTEXT Data object is used for extreme text string storage use cases. This is a viable option when the MEDIUMTEXT object is not large enough. Computer programs and applications often achieve text lengths in the LONGTEXT range. These data objects can be up to 4 GB in size (expressed as 2^32 -1), store up to 4,294,967,295 characters, and require 4 bytes of overhead storage

Please note that the number of characters that can be stored in a column depends on the character encoding.

P粉107772015

Text can handle up to 65,535 characters

Long text can handle up to 4,294,967,295 characters

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template