MySQL Tutorials - Herong's Tutorial Examples - v4.46, by Herong Yang
Table Column Types for LOB (Large OBject)
Describes 8 types of table columns to store LOB (Large OBject) data: TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT.
There are 8 types of table columns to store LOB (Large OBject) data: TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT.
"TINYBLOB" - BLOB (Binary Large OBject) data with less than 28 bytes.
"BLOB" - BLOB (Binary Large OBject) data with less than 216 bytes.
"MEDIUMBLOB" - BLOB (Binary Large OBject) data with less than 224 bytes.
"LONGBLOB" - BLOB (Binary Large OBject) data with less than 232 bytes.
"TINYTEXT" - CLOB (Character Large OBject) data with less than 28 bytes.
"TEXT" - CLOB (Character Large OBject) data with less than 216 bytes.
"MEDIUMTEXT" - CLOB (Character Large OBject) data with less than 224 bytes.
"LONGTEXT" - CLOB (Character Large OBject) data with less than 232 bytes.
Examples of BLOB/CLOB column types, BlobClobColumns.sql:
-- BlobClobColumns.sql -- Copyright (c) 2005 HerongYang.com. All Rights Reserved. -- CREATE TABLE BlobClob ( Line VARCHAR(2), B BLOB, T TEXT ); INSERT INTO BlobClob VALUES ( '1', 'AAA', 'AAA' ); INSERT INTO BlobClob VALUES ( '2', X'424242', X'424242' ); INSERT INTO BlobClob VALUES ( '3', BINARY(X'434343'), BINARY(X'434343') ); SELECT * FROM BlobClob; DROP TABLE BlobClob;
Running BlobClobColumns.sql on MySQL 8.0 server gives you:
herong> %mysql%\bin\mysql --user=root --password=TopSecret test \ < BlobClobColumns.sql Line B T 1 AAA AAA 2 BBB BBB 3 CCC CCC
Note that BLOB and CLOB behave the same way if you use them to store ASCII characters.
Table of Contents
MySQL Introduction and Installation
Introduction of MySQL Programs
Perl Programs and MySQL Servers
Java Programs and MySQL Servers
Character Strings and Bit Strings
►Table Column Types for Different Types of Values
Table Column Types for Character Strings
Table Column Types for Byte Strings
Table Column Types for Bit Strings
Table Column Types for Exact Numbers
Table Column Types for Approximate Numbers
Table Column Types for Date and Time Values
►Table Column Types for LOB (Large OBject)
Table Column Types for Look Up Values
Table Column Types for JSON Documents
Table Column Types for Spatial Geometry Data
Using DDL to Create Tables and Indexes
Using DML to Insert, Update and Delete Records
Using SELECT to Query Database
Window Functions for Statistical Analysis
Use Index for Better Performance
Transaction Management and Isolation Levels
Defining and Calling Stored Procedures
Variables, Loops and Cursors Used in Stored Procedures
System, User-Defined and Stored Procedure Variables
Storage Engines in MySQL Server
InnoDB Storage Engine - Primary and Secondary Indexes
Performance Tuning and Optimization
Installing MySQL Server on Linux