
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
TEXT Data Type in MySQL
TEXT data objects are useful for storing long-form text strings in a MySQL database. Followings are some point about TEXT data type −
- TEXT is the family of column type intended as high-capacity character storage.
- The actual TEXT column type is of four types-TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT.
- The four TEXT types are very similar to each other; the only difference is the maximum amount of data each can store.
- The smallest TEXT type, TINYTEXT shares the same character length as VARCHAR.
- TEXT values are treated as character strings.
- TEXT has character set other than binary character set and collation.
- The comparisons and sorting are based on the collation of its character set.
- Truncation of excess trailing spaces from values to be inserted into TEXT columns always generates a warning, regardless of the SQL mode.
- A TEXT family column is just like a VARCHAR.
- TEXT column cannot have DEFAULT value.
Example
Following example shows how to declare a column as TEXT.
mysql> Create table magzine(id INT, title Varchar(25), Introduction TEXT); Query OK, 0 rows affected (0.16 sec) mysql> Describe magzine; +--------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | title | varchar(25) | YES | | NULL | | | Introduction | text | YES | | NULL | | +--------------+-------------+------+-----+---------+-------+ 3 rows in set (0.11 sec)
Advertisements