Best data type for storing large strings in MySQL?


You can use text data type to store large strings. Following is the syntax −

CREATE TABLE yourTableName
(
   yourColumnName text,
   .
   .
   N
);

Let us first create a table −

mysql> create table DemoTable
   -> (
   -> MyStringValue text
   -> );
Query OK, 0 rows affected (0.67 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable values('This is a text data type to store large string'); Query OK, 1 row affected (0.17 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output −

+------------------------------------------------+
| MyStringValue                                  |
+------------------------------------------------+
| This is a text data type to store large string |
+------------------------------------------------+
1 row in set (0.00 sec)

Updated on: 30-Jul-2019

723 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements