-4

Hi I would like to know the answers of the following queries,

  1. What is the maximum size of data a TEXT data type can have in mysql table?
  2. If I would like to store 6000 to 7000 lines of texts (say, LARGE Text) in a particular field what should be the datatype of that field?
  3. What is the process to retrieve the LARGE TEXT data from mysql table in the following two cases using PHP,

Case-1 : Retrieve data from a particular field "Messages"

---------------------------
id   |   Messages
---------------------------
1    |  "here LARGE Text... 

Case-2 : Retrieve all "Messages" data from a the table.

---------------------------
id   |   Messages
---------------------------
1    |  "here LARGE Text... 
---------------------------
2    | "here another LARGE Text...

1 Answers1

0
  1. Maximum size of TEXT data type is 65,535 bytes - reference
  2. 6000-7000 lines of texts can be in TEXT or, if too long, MEDIUMTEXT (16,777,215 bytes ~16MB) - reference
  3. Same as any other MySQL retrieval format. For example, using PDO:

// Create connection
$dbh = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'username', 'password');

//Create and execute query
$stmt = $dbh->query("SELECT `messages` FROM `table`");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $row){
    echo $row["messages"];
}
Ben
  • 8,894
  • 7
  • 44
  • 80