Disreguard Females Aquire Currency

A man walks into a bar and says ouch.

I only like NY as a friend.

On a scale of 1 to Chris Brown, how mad would you be if i ate your golfish? Very angry, as my goldfish is not food.

Q: A football coach walks into a bank. Why? A: Because one of his players is suffering from terminal cancer and he needs governmental funding for the team to play the big game against their rivals and to win, in hopes the kid will recover. Q: Why did the football coach go into the bank again? A: To receive more money to find a new running back.

Chuck Norris never shows emotion!!!... because he is a pragmatic person and thinks in a more logical manner.

OSS ARE RED VIOLENTS IS BLUE U BELONG THE ZOO I WILL BE THERE TO BUT LAUGHIN AT U

What do you call a black guy with a shotgun? A fine American citizen exercising his 2nd Amendment right.

Why did the chicken cross the road? Because I told him to. I'm very influential.

Your mother is such a whore that she has consensual sex with a lot of people...

You have cancer

whats up with that? i'm from jersy

Fred: Hey man where were you last night. Steve: Why don't yo ask yo mama.

A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. The four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements. See Section 11.7, “Data Type Storage Requirements”. BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values. TEXT values are treated as nonbinary strings (character strings). They have a character set, and values are sorted and compared based on the collation of the character set. If strict SQL mode is not enabled and you assign a value to a BLOB or TEXT column that exceeds the column's maximum length, the value is truncated to fit and a warning is generated. For truncation of nonspace characters, you can cause an error to occur (rather than a warning) and suppress insertion of the value by using strict SQL mode. See Section 5.1.7, “Server SQL Modes”. Beginning with MySQL 5.0.60, truncation of excess trailing spaces from values to be inserted into TEXT columns always generates a warning, regardless of the SQL mode. For TEXT and BLOB columns, there is no padding on insert and no bytes are stripped on select. If a TEXT column is indexed, index entry comparisons are space-padded at the end. This means that, if the index requires unique values, duplicate-key errors will occur for values that differ only in the number of trailing spaces. For example, if a table contains 'a', an attempt to store 'a ' causes a duplicate-key error. This is not true for BLOB columns. In most respects, you can regard a BLOB column as a VARBINARY column that can be as large as you like. Similarly, you can regard a TEXT column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways: There is no trailing-space removal for BLOB and TEXT columns when values are stored or retrieved. Before MySQL 5.0.3, this differs from VARBINARY and VARCHAR, for which trailing spaces are removed when values are stored. On comparisons, TEXT is space extended to fit the compared object, exactly like CHAR and VARCHAR. For indexes on BLOB and TEXT columns, you must specify an index prefix length. For CHAR and VARCHAR, a prefix length is optional. See Section 8.3.4, “Column Indexes”. BLOB and TEXT columns cannot have DEFAULT values. If you use the BINARY attribute with a TEXT data type, the column is assigned the binary collation of the column character set. LONG and LONG VARCHAR map to the MEDIUMTEXT data type. This is a compatibility feature. MySQL Connector/ODBC defines BLOB values as LONGVARBINARY and TEXT values as LONGVARCHAR. Because BLOB and TEXT values can be extremely long, you might encounter some constraints in using them: Only the first max_sort_length bytes of the column are used when sorting. The default value of max_sort_length is 1024. You can make more bytes significant in sorting or grouping by increasing the value of max_sort_length at server startup or runtime. Any client can change the value of its session max_sort_length variable: mysql> SET max_sort_length = 2000; mysql> SELECT id, comment FROM t -> ORDER BY comment; Instances of BLOB or TEXT columns in the result of a query that is processed using a temporary table causes the server to use a table on disk rather than in memory because the MEMORY storage engine does not support those data types (see Section 8.4.4, “How MySQL Uses Internal Temporary Tables”). Use of disk incurs a performance penalty, so include BLOB or TEXT columns in the query result only if they are really needed. For example, avoid using SELECT *, which selects all columns. The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications buffers. You can change the message buffer size by changing the value of the max_allowed_packet variable, but you must do so for both the server and your client program. For example, both mysql and mysqldump enable you to change the client-side max_allowed_packet value. See Section 8.12.2, “Tuning Server Parameters”, Section 4.5.1, “mysql — The MySQL Command-Line Tool”, and Section 4.5.4, “mysqldump — A Database Backup Program”. You may also want to compare the packet sizes and the size of the data objects you are storing with the storage requirements, see Section 11.7, “Data Type Storage Requirements” Each BLOB or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened. In some cases, it may be desirable to store binary data such as media files in BLOB or TEXT columns. You may find MySQL's string handling functions useful for working with such data. See Section 12.5, “String Functions”. For security and other reasons, it is usually preferable to do so using application code rather than giving application users the FILE privilege. You can discuss specifics for various languages and platforms in the MySQL Forums (http://forums.mysql.com/). Previous / Next / Up / Table of Contents User Comments Posted by Volnei Puttini on June 22 2007 12:04pm [Delete] [Edit] A pratical example of how write and read images into MySQL tables, using Trolltech Qt4/C++ This example is for who reads/record images in tables using fields BLOB. First: Create a table, for example: CREATE TABLE picture ( ID INTEGER AUTO_INCREMENT, IMAGE BLOB, PRIMARY KEY (ID) ) ENGINE=InnoDB; 2) To read a image to a QByteArray QString fileName = "IMAGE.JPG"; QImage image(filaName); LBL_IMAGE->setPixmap(QPixmap::fromImage(image)); // Put image into QLabel object (optional) // load image to bytearray QByteArray ba; QFile f(fileName); if(f.open(QIODevice::ReadOnly)) { ba = f.readAll(); f.close(); } // Writing the image into table QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare( "INSERT INTO picture ( IMAGE ) VALUES (:IMAGE)" ); query.bindValue(":IMAGE", ba); query.exec(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else QSqlDatabase::database().commit(); 3) Now, recovery the field with the image int idx = 1; // The records ID to recover QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare("SELECT ID, IMAGE FROM picture WHERE ID=:ID"); query.bindValue(":ID", idx); query.exec(); query.next(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else { QByteArray ba1 = query.value(1).toByteArray(); QPixmap pic; pic.loadFromData( ba1); // Show the image into a QLabel object LBL_IMAGE->setPixmap(pic); QSqlDatabase::database().commit(); } This example works fine and I use it frequently. Thanks. Posted by Bryce Nesbitt on April 4 2008 4:36pm [Delete] [Edit] On MS Windows the "no DEFAULT" rule is an error, while on other platforms it is often a warning. While not a bug, it's possible to get trapped by this if you write code on a lenient platform, and later run it on a strict platform: mysql> show warnings; +---------+------+------------------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------------------+ | Warning | 1101 | BLOB/TEXT column 'abcdef' can't have a default value | +---------+------+------------------------------------------------------+ Posted by [name withheld] on April 27 2008 11:17am [Delete] [Edit] I struggled for some time to utilize mysql's blob column to store images and especially large files with good performance in and out. I found this tutorials implementation very useful: http://www.dreamwerx.net/phpforum/?id=1 Posted by Rajiv Kapoor on December 9 2008 9:46am [Delete] [Edit] Following way we can store blob data in a table using MYSQL: INSERT INTO PICTABLE (MYID, PIC) VALUES (3, LOAD_FILE('/PHP/ME.JPG')); Posted by Kristian Köhntopp on October 2 2009 3:19pm [Delete] [Edit] Simon Mudd is right, but there are several things that must come together to make this bad: 1. You must have a query that has an EXPLAIN which includes 'using temporary'. If 'using temporary' is shown in your EXPLAIN plan, then a temporary table is being created either in MEMORY or as MyISAM table on disk. MySQL prefers MEMORY, but there are situations where it is forced to go to disk. 2. You must have a query which includes any TEXT or BLOB type in the column list, that is in the part of the query between SELECT and FROM. The actual size of the column or its content do not matter - even a TINYTEXT that is empty is enough. Since the MEMORY storage engine cannot represent any TEXT or BLOB types at all, this forces MySQL to realize the table as an on-disk MyISAM table. How to diagnose: 1. Run show session status: kris@localhost [test_world]> show session status like 'Created_tmp%tables'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 3 | | Created_tmp_tables | 7 | +-------------------------+-------+ 2 rows in set (0.00 sec) 2. Execute the query. Make sure it is not cached: kris@localhost [test_world]> select sql_no_cache * from kris group by countrycode order by population; ... 232 rows in set (0.00 sec) 3. Check show status again: kris@localhost [test_world]> show session status like 'Created_tmp%tables'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 4 | | Created_tmp_tables | 8 | +-------------------------+-------+ 2 rows in set (0.00 sec) As you can see the Created_tmp_tables counter increased by one (in MySQL 5.0 is increases by two because the SHOW STATUS itself creates an in-memory tmp table which is being counted). If the table goes to disk as MyISAM instead of being a MEMORY Table, Created_tmp_disk_tables is also incremented by one, as seen here. This is slow. The test table I used is using the MySQL world database and mysql> create table kris as select * from City; mysql> alter table kris modify column name text; mysql> alter table kris add primary key (id); The test query shown above is 'using temporary' because I group by one column and order by another, forcing MySQL to use a temporary table. Had I been using the same query on the original City table from the world database, a tmp table would have been needed as well, but it would have been created as a MEMORY table as the original name column is a CHAR(35). So Created_tmp_tables is being bumped by one, but Created_tmp_disk_tables is not. Had I been leaving off the SQL_NO_CACHE, the query cache would have been catching repeated executions of the same query in testing and the counters would not have been moving at all except for the very first test. Posted by TM Sch on April 21 2012 8:00am [Delete] [Edit] This was my first time working with BLOB data, but I first wanted to test WITHOUT an intermediary programming language. (That would add another source of errors, I think.) I had a hard time trying to test inserting and selecting. Probably this is old had to professional programmers, but my book's limited discussion of BLOB data was about the data type, not how to use it. Newbies, to make your life easier, here's a quick how-to insert/return blob data at the command line: **** 1) Got errors about NULL value in NOT NULL column. Permissions were fixed as far as I could see (have MySQL installed as a service on Windows 7, and all users had at least read/execute permissions). I did not see any "max_allowed_packet" or "secure_file_priv" already existing in the "my.ini" file. SOLUTION: In addition to proper permissions, I need to use "/", not "\" in path to blob data (which was a picture). Note, this worked properly even for a non-relative path starting at the drive letter! :D Meanwhile, I tried moving the photo to a new directory to solve my so-called "permissions" problem, but that wasn't the problem. Truly, I was getting Error 1048 was because I needed to use forward slashes! (You will get Error 1048 if you try to insert a NULL value, or when using LOAD_FILE and it can't read it for any reason...not always permissions.) 2) After solving #1, SELECT statement seemed to confirm the picture is indeed stored in the table. However, this returned so many unreadable characters that I could not scroll back to see the complete results, and I had to wait a couple minutes until my computer stopped beeping. (Lucky for me, the system didn't crash.) SOLUTION: use the SUBSTRING() function in the SELECT statement to only return so many characters from that blob field! ** SAMPLE DATA IF YOU WANT TO TRY YOURSELF ** ** Edited, forgot to use double-backslashes in "Filename" column. ** CREATE TABLE Photos( PhotoID int unsigned not null auto_increment primary key, Filename varchar(255) not null unique, Caption varchar(255) not null, Photo longblob not null); DESCRIBE Photos; INSERT INTO Photos values ( NULL, 'D:\\mytemp\\WOC-logo.jpg', 'Walk of Champions official logo', LOAD_FILE('D:/mytemp/WOC-logo.jpg') ); SELECT PhotoID, Filename, Caption, SUBSTRING(Photo,1,20) from Photos; Add your own comment Top / Previous / Next / Up / Table of Contents Developer Zone Developer Articles Forums Bugs Worklog Planet MySQL Downloads MySQL Community Server MySQL Cluster MySQL Fabric MySQL Utilities MySQL Workbench Documentation MySQL Reference Manuals MySQL Workbench Expert Guides Topic Guides MySQL Cluster About MySQL Contact Us How to Buy Partners Job Opportunities Site Map A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. The four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements. See Section 11.7, “Data Type Storage Requirements”. BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values. TEXT values are treated as nonbinary strings (character strings). They have a character set, and values are sorted and compared based on the collation of the character set. If strict SQL mode is not enabled and you assign a value to a BLOB or TEXT column that exceeds the column's maximum length, the value is truncated to fit and a warning is generated. For truncation of nonspace characters, you can cause an error to occur (rather than a warning) and suppress insertion of the value by using strict SQL mode. See Section 5.1.7, “Server SQL Modes”. Beginning with MySQL 5.0.60, truncation of excess trailing spaces from values to be inserted into TEXT columns always generates a warning, regardless of the SQL mode. For TEXT and BLOB columns, there is no padding on insert and no bytes are stripped on select. If a TEXT column is indexed, index entry comparisons are space-padded at the end. This means that, if the index requires unique values, duplicate-key errors will occur for values that differ only in the number of trailing spaces. For example, if a table contains 'a', an attempt to store 'a ' causes a duplicate-key error. This is not true for BLOB columns. In most respects, you can regard a BLOB column as a VARBINARY column that can be as large as you like. Similarly, you can regard a TEXT column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways: There is no trailing-space removal for BLOB and TEXT columns when values are stored or retrieved. Before MySQL 5.0.3, this differs from VARBINARY and VARCHAR, for which trailing spaces are removed when values are stored. On comparisons, TEXT is space extended to fit the compared object, exactly like CHAR and VARCHAR. For indexes on BLOB and TEXT columns, you must specify an index prefix length. For CHAR and VARCHAR, a prefix length is optional. See Section 8.3.4, “Column Indexes”. BLOB and TEXT columns cannot have DEFAULT values. If you use the BINARY attribute with a TEXT data type, the column is assigned the binary collation of the column character set. LONG and LONG VARCHAR map to the MEDIUMTEXT data type. This is a compatibility feature. MySQL Connector/ODBC defines BLOB values as LONGVARBINARY and TEXT values as LONGVARCHAR. Because BLOB and TEXT values can be extremely long, you might encounter some constraints in using them: Only the first max_sort_length bytes of the column are used when sorting. The default value of max_sort_length is 1024. You can make more bytes significant in sorting or grouping by increasing the value of max_sort_length at server startup or runtime. Any client can change the value of its session max_sort_length variable: mysql> SET max_sort_length = 2000; mysql> SELECT id, comment FROM t -> ORDER BY comment; Instances of BLOB or TEXT columns in the result of a query that is processed using a temporary table causes the server to use a table on disk rather than in memory because the MEMORY storage engine does not support those data types (see Section 8.4.4, “How MySQL Uses Internal Temporary Tables”). Use of disk incurs a performance penalty, so include BLOB or TEXT columns in the query result only if they are really needed. For example, avoid using SELECT *, which selects all columns. The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications buffers. You can change the message buffer size by changing the value of the max_allowed_packet variable, but you must do so for both the server and your client program. For example, both mysql and mysqldump enable you to change the client-side max_allowed_packet value. See Section 8.12.2, “Tuning Server Parameters”, Section 4.5.1, “mysql — The MySQL Command-Line Tool”, and Section 4.5.4, “mysqldump — A Database Backup Program”. You may also want to compare the packet sizes and the size of the data objects you are storing with the storage requirements, see Section 11.7, “Data Type Storage Requirements” Each BLOB or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened. In some cases, it may be desirable to store binary data such as media files in BLOB or TEXT columns. You may find MySQL's string handling functions useful for working with such data. See Section 12.5, “String Functions”. For security and other reasons, it is usually preferable to do so using application code rather than giving application users the FILE privilege. You can discuss specifics for various languages and platforms in the MySQL Forums (http://forums.mysql.com/). Previous / Next / Up / Table of Contents User Comments Posted by Volnei Puttini on June 22 2007 12:04pm [Delete] [Edit] A pratical example of how write and read images into MySQL tables, using Trolltech Qt4/C++ This example is for who reads/record images in tables using fields BLOB. First: Create a table, for example: CREATE TABLE picture ( ID INTEGER AUTO_INCREMENT, IMAGE BLOB, PRIMARY KEY (ID) ) ENGINE=InnoDB; 2) To read a image to a QByteArray QString fileName = "IMAGE.JPG"; QImage image(filaName); LBL_IMAGE->setPixmap(QPixmap::fromImage(image)); // Put image into QLabel object (optional) // load image to bytearray QByteArray ba; QFile f(fileName); if(f.open(QIODevice::ReadOnly)) { ba = f.readAll(); f.close(); } // Writing the image into table QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare( "INSERT INTO picture ( IMAGE ) VALUES (:IMAGE)" ); query.bindValue(":IMAGE", ba); query.exec(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else QSqlDatabase::database().commit(); 3) Now, recovery the field with the image int idx = 1; // The records ID to recover QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare("SELECT ID, IMAGE FROM picture WHERE ID=:ID"); query.bindValue(":ID", idx); query.exec(); query.next(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else { QByteArray ba1 = query.value(1).toByteArray(); QPixmap pic; pic.loadFromData( ba1); // Show the image into a QLabel object LBL_IMAGE->setPixmap(pic); QSqlDatabase::database().commit(); } This example works fine and I use it frequently. Thanks. Posted by Bryce Nesbitt on April 4 2008 4:36pm [Delete] [Edit] On MS Windows the "no DEFAULT" rule is an error, while on other platforms it is often a warning. While not a bug, it's possible to get trapped by this if you write code on a lenient platform, and later run it on a strict platform: mysql> show warnings; +---------+------+------------------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------------------+ | Warning | 1101 | BLOB/TEXT column 'abcdef' can't have a default value | +---------+------+------------------------------------------------------+ Posted by [name withheld] on April 27 2008 11:17am [Delete] [Edit] I struggled for some time to utilize mysql's blob column to store images and especially large files with good performance in and out. I found this tutorials implementation very useful: http://www.dreamwerx.net/phpforum/?id=1 Posted by Rajiv Kapoor on December 9 2008 9:46am [Delete] [Edit] Following way we can store blob data in a table using MYSQL: INSERT INTO PICTABLE (MYID, PIC) VALUES (3, LOAD_FILE('/PHP/ME.JPG')); Posted by Kristian Köhntopp on October 2 2009 3:19pm [Delete] [Edit] Simon Mudd is right, but there are several things that must come together to make this bad: 1. You must have a query that has an EXPLAIN which includes 'using temporary'. If 'using temporary' is shown in your EXPLAIN plan, then a temporary table is being created either in MEMORY or as MyISAM table on disk. MySQL prefers MEMORY, but there are situations where it is forced to go to disk. 2. You must have a query which includes any TEXT or BLOB type in the column list, that is in the part of the query between SELECT and FROM. The actual size of the column or its content do not matter - even a TINYTEXT that is empty is enough. Since the MEMORY storage engine cannot represent any TEXT or BLOB types at all, this forces MySQL to realize the table as an on-disk MyISAM table. How to diagnose: 1. Run show session status: kris@localhost [test_world]> show session status like 'Created_tmp%tables'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 3 | | Created_tmp_tables | 7 | +-------------------------+-------+ 2 rows in set (0.00 sec) 2. Execute the query. Make sure it is not cached: kris@localhost [test_world]> select sql_no_cache * from kris group by countrycode order by population; ... 232 rows in set (0.00 sec) 3. Check show status again: kris@localhost [test_world]> show session status like 'Created_tmp%tables'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 4 | | Created_tmp_tables | 8 | +-------------------------+-------+ 2 rows in set (0.00 sec) As you can see the Created_tmp_tables counter increased by one (in MySQL 5.0 is increases by two because the SHOW STATUS itself creates an in-memory tmp table which is being counted). If the table goes to disk as MyISAM instead of being a MEMORY Table, Created_tmp_disk_tables is also incremented by one, as seen here. This is slow. The test table I used is using the MySQL world database and mysql> create table kris as select * from City; mysql> alter table kris modify column name text; mysql> alter table kris add primary key (id); The test query shown above is 'using temporary' because I group by one column and order by another, forcing MySQL to use a temporary table. Had I been using the same query on the original City table from the world database, a tmp table would have been needed as well, but it would have been created as a MEMORY table as the original name column is a CHAR(35). So Created_tmp_tables is being bumped by one, but Created_tmp_disk_tables is not. Had I been leaving off the SQL_NO_CACHE, the query cache would have been catching repeated executions of the same query in testing and the counters would not have been moving at all except for the very first test. Posted by TM Sch on April 21 2012 8:00am [Delete] [Edit] This was my first time working with BLOB data, but I first wanted to test WITHOUT an intermediary programming language. (That would add another source of errors, I think.) I had a hard time trying to test inserting and selecting. Probably this is old had to professional programmers, but my book's limited discussion of BLOB data was about the data type, not how to use it. Newbies, to make your life easier, here's a quick how-to insert/return blob data at the command line: **** 1) Got errors about NULL value in NOT NULL column. Permissions were fixed as far as I could see (have MySQL installed as a service on Windows 7, and all users had at least read/execute permissions). I did not see any "max_allowed_packet" or "secure_file_priv" already existing in the "my.ini" file. SOLUTION: In addition to proper permissions, I need to use "/", not "\" in path to blob data (which was a picture). Note, this worked properly even for a non-relative path starting at the drive letter! :D Meanwhile, I tried moving the photo to a new directory to solve my so-called "permissions" problem, but that wasn't the problem. Truly, I was getting Error 1048 was because I needed to use forward slashes! (You will get Error 1048 if you try to insert a NULL value, or when using LOAD_FILE and it can't read it for any reason...not always permissions.) 2) After solving #1, SELECT statement seemed to confirm the picture is indeed stored in the table. However, this returned so many unreadable characters that I could not scroll back to see the complete results, and I had to wait a couple minutes until my computer stopped beeping. (Lucky for me, the system didn't crash.) SOLUTION: use the SUBSTRING() function in the SELECT statement to only return so many characters from that blob field! ** SAMPLE DATA IF YOU WANT TO TRY YOURSELF ** ** Edited, forgot to use double-backslashes in "Filename" column. ** CREATE TABLE Photos( PhotoID int unsigned not null auto_increment primary key, Filename varchar(255) not null unique, Caption varchar(255) not null, Photo longblob not null); DESCRIBE Photos; INSERT INTO Photos values ( NULL, 'D:\\mytemp\\WOC-logo.jpg', 'Walk of Champions official logo', LOAD_FILE('D:/mytemp/WOC-logo.jpg') ); SELECT PhotoID, Filename, Caption, SUBSTRING(Photo,1,20) from Photos; Add your own comment Top / Previous / Next / Up / Table of Contents Developer Zone Developer Articles Forums Bugs Worklog Planet MySQL Downloads MySQL Community Server MySQL Cluster MySQL Fabric MySQL Utilities MySQL Workbench Documentation MySQL Reference Manuals MySQL Workbench Expert Guides Topic Guides MySQL Cluster About MySQL Contact Us How to Buy Partners Job Opportunities Site Map Legal Legal Policies Your Privacy Rights Terms of Use Trademark Policy Contributor Agreement Search Legal Legal Policies A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. The four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements. See Section 11.7, “Data Type Storage Requirements”. BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values. TEXT values are treated as nonbinary strings (character strings). They have a character set, and values are sorted and compared based on the collation of the character set. If strict SQL mode is not enabled and you assign a value to a BLOB or TEXT column that exceeds the column's maximum length, the value is truncated to fit and a warning is generated. For truncation of nonspace characters, you can cause an error to occur (rather than a warning) and suppress insertion of the value by using strict SQL mode. See Section 5.1.7, “Server SQL Modes”. Beginning with MySQL 5.0.60, truncation of excess trailing spaces from values to be inserted into TEXT columns always generates a warning, regardless of the SQL mode. For TEXT and BLOB columns, there is no padding on insert and no bytes are stripped on select. If a TEXT column is indexed, index entry comparisons are space-padded at the end. This means that, if the index requires unique values, duplicate-key errors will occur for values that differ only in the number of trailing spaces. For example, if a table contains 'a', an attempt to store 'a ' causes a duplicate-key error. This is not true for BLOB columns. In most respects, you can regard a BLOB column as a VARBINARY column that can be as large as you like. Similarly, you can regard a TEXT column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways: There is no trailing-space removal for BLOB and TEXT columns when values are stored or retrieved. Before MySQL 5.0.3, this differs from VARBINARY and VARCHAR, for which trailing spaces are removed when values are stored. On comparisons, TEXT is space extended to fit the compared object, exactly like CHAR and VARCHAR. For indexes on BLOB and TEXT columns, you must specify an index prefix length. For CHAR and VARCHAR, a prefix length is optional. See Section 8.3.4, “Column Indexes”. BLOB and TEXT columns cannot have DEFAULT values. If you use the BINARY attribute with a TEXT data type, the column is assigned the binary collation of the column character set. LONG and LONG VARCHAR map to the MEDIUMTEXT data type. This is a compatibility feature. MySQL Connector/ODBC defines BLOB values as LONGVARBINARY and TEXT values as LONGVARCHAR. Because BLOB and TEXT values can be extremely long, you might encounter some constraints in using them: Only the first max_sort_length bytes of the column are used when sorting. The default value of max_sort_length is 1024. You can make more bytes significant in sorting or grouping by increasing the value of max_sort_length at server startup or runtime. Any client can change the value of its session max_sort_length variable: mysql> SET max_sort_length = 2000; mysql> SELECT id, comment FROM t -> ORDER BY comment; Instances of BLOB or TEXT columns in the result of a query that is processed using a temporary table causes the server to use a table on disk rather than in memory because the MEMORY storage engine does not support those data types (see Section 8.4.4, “How MySQL Uses Internal Temporary Tables”). Use of disk incurs a performance penalty, so include BLOB or TEXT columns in the query result only if they are really needed. For example, avoid using SELECT *, which selects all columns. The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications buffers. You can change the message buffer size by changing the value of the max_allowed_packet variable, but you must do so for both the server and your client program. For example, both mysql and mysqldump enable you to change the client-side max_allowed_packet value. See Section 8.12.2, “Tuning Server Parameters”, Section 4.5.1, “mysql — The MySQL Command-Line Tool”, and Section 4.5.4, “mysqldump — A Database Backup Program”. You may also want to compare the packet sizes and the size of the data objects you are storing with the storage requirements, see Section 11.7, “Data Type Storage Requirements” Each BLOB or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened. In some cases, it may be desirable to store binary data such as media files in BLOB or TEXT columns. You may find MySQL's string handling functions useful for working with such data. See Section 12.5, “String Functions”. For security and other reasons, it is usually preferable to do so using application code rather than giving application users the FILE privilege. You can discuss specifics for various languages and platforms in the MySQL Forums (http://forums.mysql.com/). Previous / Next / Up / Table of Contents User Comments Posted by Volnei Puttini on June 22 2007 12:04pm [Delete] [Edit] A pratical example of how write and read images into MySQL tables, using Trolltech Qt4/C++ This example is for who reads/record images in tables using fields BLOB. First: Create a table, for example: CREATE TABLE picture ( ID INTEGER AUTO_INCREMENT, IMAGE BLOB, PRIMARY KEY (ID) ) ENGINE=InnoDB; 2) To read a image to a QByteArray QString fileName = "IMAGE.JPG"; QImage image(filaName); LBL_IMAGE->setPixmap(QPixmap::fromImage(image)); // Put image into QLabel object (optional) // load image to bytearray QByteArray ba; QFile f(fileName); if(f.open(QIODevice::ReadOnly)) { ba = f.readAll(); f.close(); } // Writing the image into table QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare( "INSERT INTO picture ( IMAGE ) VALUES (:IMAGE)" ); query.bindValue(":IMAGE", ba); query.exec(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else QSqlDatabase::database().commit(); 3) Now, recovery the field with the image int idx = 1; // The records ID to recover QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare("SELECT ID, IMAGE FROM picture WHERE ID=:ID"); query.bindValue(":ID", idx); query.exec(); query.next(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else { QByteArray ba1 = query.value(1).toByteArray(); QPixmap pic; pic.loadFromData( ba1); // Show the image into a QLabel object LBL_IMAGE->setPixmap(pic); QSqlDatabase::database().commit(); } This example works fine and I use it frequently. Thanks. Posted by Bryce Nesbitt on April 4 2008 4:36pm [Delete] [Edit] On MS Windows the "no DEFAULT" rule is an error, while on other platforms it is often a warning. While not a bug, it's possible to get trapped by this if you write code on a lenient platform, and later run it on a strict platform: mysql> show warnings; +---------+------+------------------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------------------+ | Warning | 1101 | BLOB/TEXT column 'abcdef' can't have a default value | +---------+------+------------------------------------------------------+ Posted by [name withheld] on April 27 2008 11:17am [Delete] [Edit] I struggled for some time to utilize mysql's blob column to store images and especially large files with good performance in and out. I found this tutorials implementation very useful: http://www.dreamwerx.net/phpforum/?id=1 Posted by Rajiv Kapoor on December 9 2008 9:46am [Delete] [Edit] Following way we can store blob data in a table using MYSQL: INSERT INTO PICTABLE (MYID, PIC) VALUES (3, LOAD_FILE('/PHP/ME.JPG')); Posted by Kristian Köhntopp on October 2 2009 3:19pm [Delete] [Edit] Simon Mudd is right, but there are several things that must come together to make this bad: 1. You must have a query that has an EXPLAIN which includes 'using temporary'. If 'using temporary' is shown in your EXPLAIN plan, then a temporary table is being created either in MEMORY or as MyISAM table on disk. MySQL prefers MEMORY, but there are situations where it is forced to go to disk. 2. You must have a query which includes any TEXT or BLOB type in the column list, that is in the part of the query between SELECT and FROM. The actual size of the column or its content do not matter - even a TINYTEXT that is empty is enough. Since the MEMORY storage engine cannot represent any TEXT or BLOB types at all, this forces MySQL to realize the table as an on-disk MyISAM table. How to diagnose: 1. Run show session status: kris@localhost [test_world]> show session status like 'Created_tmp%tables'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 3 | | Created_tmp_tables | 7 | +-------------------------+-------+ 2 rows in set (0.00 sec) 2. Execute the query. Make sure it is not cached: kris@localhost [test_world]> select sql_no_cache * from kris group by countrycode order by population; ... 232 rows in set (0.00 sec) 3. Check show status again: kris@localhost [test_world]> show session status like 'Created_tmp%tables'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 4 | | Created_tmp_tables | 8 | +-------------------------+-------+ 2 rows in set (0.00 sec) As you can see the Created_tmp_tables counter increased by one (in MySQL 5.0 is increases by two because the SHOW STATUS itself creates an in-memory tmp table which is being counted). If the table goes to disk as MyISAM instead of being a MEMORY Table, Created_tmp_disk_tables is also incremented by one, as seen here. This is slow. The test table I used is using the MySQL world database and mysql> create table kris as select * from City; mysql> alter table kris modify column name text; mysql> alter table kris add primary key (id); The test query shown above is 'using temporary' because I group by one column and order by another, forcing MySQL to use a temporary table. Had I been using the same query on the original City table from the world database, a tmp table would have been needed as well, but it would have been created as a MEMORY table as the original name column is a CHAR(35). So Created_tmp_tables is being bumped by one, but Created_tmp_disk_tables is not. Had I been leaving off the SQL_NO_CACHE, the query cache would have been catching repeated executions of the same query in testing and the counters would not have been moving at all except for the very first test. Posted by TM Sch on April 21 2012 8:00am [Delete] [Edit] This was my first time working with BLOB data, but I first wanted to test WITHOUT an intermediary programming language. (That would add another source of errors, I think.) I had a hard time trying to test inserting and selecting. Probably this is old had to professional programmers, but my book's limited discussion of BLOB data was about the data type, not how to use it. Newbies, to make your life easier, here's a quick how-to insert/return blob data at the command line: **** 1) Got errors about NULL value in NOT NULL column. Permissions were fixed as far as I could see (have MySQL installed as a service on Windows 7, and all users had at least read/execute permissions). I did not see any "max_allowed_packet" or "secure_file_priv" already existing in the "my.ini" file. SOLUTION: In addition to proper permissions, I need to use "/", not "\" in path to blob data (which was a picture). Note, this worked properly even for a non-relative path starting at the drive letter! :D Meanwhile, I tried moving the photo to a new directory to solve my so-called "permissions" problem, but that wasn't the problem. Truly, I was getting Error 1048 was because I needed to use forward slashes! (You will get Error 1048 if you try to insert a NULL value, or when using LOAD_FILE and it can't read it for any reason...not always permissions.) 2) After solving #1, SELECT statement seemed to confirm the picture is indeed stored in the table. However, this returned so many unreadable characters that I could not scroll back to see the complete results, and I had to wait a couple minutes until my computer stopped beeping. (Lucky for me, the system didn't crash.) SOLUTION: use the SUBSTRING() function in the SELECT statement to only return so many characters from that blob field! ** SAMPLE DATA IF YOU WANT TO TRY YOURSELF ** ** Edited, forgot to use double-backslashes in "Filename" column. ** CREATE TABLE Photos( PhotoID int unsigned not null auto_increment primary key, Filename varchar(255) not null unique, Caption varchar(255) not null, Photo longblob not null); DESCRIBE Photos; INSERT INTO Photos values ( NULL, 'D:\\mytemp\\WOC-logo.jpg', 'Walk of Champions official logo', LOAD_FILE('D:/mytemp/WOC-logo.jpg') ); SELECT PhotoID, Filename, Caption, SUBSTRING(Photo,1,20) from Photos; Add your own comment Top / Previous / Next / Up / Table of Contents Developer Zone Developer Articles Forums Bugs Worklog Planet MySQL Downloads MySQL Community Server MySQL Cluster MySQL Fabric MySQL Utilities MySQL Workbench Documentation MySQL Reference Manuals MySQL Workbench Expert Guides Topic Guides MySQL Cluster About MySQL Contact Us How to Buy Partners Job Opportunities Site Map Legal Legal Policies Your Privacy Rights Terms of Use Trademark Policy Contributor Agreement Search Your Privacy Rights A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. The four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements. See Section 11.7, “Data Type Storage Requirements”. BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values. TEXT values are treated as nonbinary strings (character strings). They have a character set, and values are sorted and compared based on the collation of the character set. If strict SQL mode is not enabled and you assign a value to a BLOB or TEXT column that exceeds the column's maximum length, the value is truncated to fit and a warning is generated. For truncation of nonspace characters, you can cause an error to occur (rather than a warning) and suppress insertion of the value by using strict SQL mode. See Section 5.1.7, “Server SQL Modes”. Beginning with MySQL 5.0.60, truncation of excess trailing spaces from values to be inserted into TEXT columns always generates a warning, regardless of the SQL mode. For TEXT and BLOB columns, there is no padding on insert and no bytes are stripped on select. If a TEXT column is indexed, index entry comparisons are space-padded at the end. This means that, if the index requires unique values, duplicate-key errors will occur for values that differ only in the number of trailing spaces. For example, if a table contains 'a', an attempt to store 'a ' causes a duplicate-key error. This is not true for BLOB columns. In most respects, you can regard a BLOB column as a VARBINARY column that can be as large as you like. Similarly, you can regard a TEXT column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways: There is no trailing-space removal for BLOB and TEXT columns when values are stored or retrieved. Before MySQL 5.0.3, this differs from VARBINARY and VARCHAR, for which trailing spaces are removed when values are stored. On comparisons, TEXT is space extended to fit the compared object, exactly like CHAR and VARCHAR. For indexes on BLOB and TEXT columns, you must specify an index prefix length. For CHAR and VARCHAR, a prefix length is optional. See Section 8.3.4, “Column Indexes”. BLOB and TEXT columns cannot have DEFAULT values. If you use the BINARY attribute with a TEXT data type, the column is assigned the binary collation of the column character set. LONG and LONG VARCHAR map to the MEDIUMTEXT data type. This is a compatibility feature. MySQL Connector/ODBC defines BLOB values as LONGVARBINARY and TEXT values as LONGVARCHAR. Because BLOB and TEXT values can be extremely long, you might encounter some constraints in using them: Only the first max_sort_length bytes of the column are used when sorting. The default value of max_sort_length is 1024. You can make more bytes significant in sorting or grouping by increasing the value of max_sort_length at server startup or runtime. Any client can change the value of its session max_sort_length variable: mysql> SET max_sort_length = 2000; mysql> SELECT id, comment FROM t -> ORDER BY comment; Instances of BLOB or TEXT columns in the result of a query that is processed using a temporary table causes the server to use a table on disk rather than in memory because the MEMORY storage engine does not support those data types (see Section 8.4.4, “How MySQL Uses Internal Temporary Tables”). Use of disk incurs a performance penalty, so include BLOB or TEXT columns in the query result only if they are really needed. For example, avoid using SELECT *, which selects all columns. The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications buffers. You can change the message buffer size by changing the value of the max_allowed_packet variable, but you must do so for both the server and your client program. For example, both mysql and mysqldump enable you to change the client-side max_allowed_packet value. See Section 8.12.2, “Tuning Server Parameters”, Section 4.5.1, “mysql — The MySQL Command-Line Tool”, and Section 4.5.4, “mysqldump — A Database Backup Program”. You may also want to compare the packet sizes and the size of the data objects you are storing with the storage requirements, see Section 11.7, “Data Type Storage Requirements” Each BLOB or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened. In some cases, it may be desirable to store binary data such as media files in BLOB or TEXT columns. You may find MySQL's string handling functions useful for working with such data. See Section 12.5, “String Functions”. For security and other reasons, it is usually preferable to do so using application code rather than giving application users the FILE privilege. You can discuss specifics for various languages and platforms in the MySQL Forums (http://forums.mysql.com/). Previous / Next / Up / Table of Contents User Comments Posted by Volnei Puttini on June 22 2007 12:04pm [Delete] [Edit] A pratical example of how write and read images into MySQL tables, using Trolltech Qt4/C++ This example is for who reads/record images in tables using fields BLOB. First: Create a table, for example: CREATE TABLE picture ( ID INTEGER AUTO_INCREMENT, IMAGE BLOB, PRIMARY KEY (ID) ) ENGINE=InnoDB; 2) To read a image to a QByteArray QString fileName = "IMAGE.JPG"; QImage image(filaName); LBL_IMAGE->setPixmap(QPixmap::fromImage(image)); // Put image into QLabel object (optional) // load image to bytearray QByteArray ba; QFile f(fileName); if(f.open(QIODevice::ReadOnly)) { ba = f.readAll(); f.close(); } // Writing the image into table QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare( "INSERT INTO picture ( IMAGE ) VALUES (:IMAGE)" ); query.bindValue(":IMAGE", ba); query.exec(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else QSqlDatabase::database().commit(); 3) Now, recovery the field with the image int idx = 1; // The records ID to recover QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare("SELECT ID, IMAGE FROM picture WHERE ID=:ID"); query.bindValue(":ID", idx); query.exec(); query.next(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else { QByteArray ba1 = query.value(1).toByteArray(); QPixmap pic; pic.loadFromData( ba1); // Show the image into a QLabel object LBL_IMAGE->setPixmap(pic); QSqlDatabase::database().commit(); } This example works fine and I use it frequently. Thanks. Posted by Bryce Nesbitt on April 4 2008 4:36pm [Delete] [Edit] On MS Windows the "no DEFAULT" rule is an error, while on other platforms it is often a warning. While not a bug, it's possible to get trapped by this if you write code on a lenient platform, and later run it on a strict platform: mysql> show warnings; +---------+------+------------------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------------------+ | Warning | 1101 | BLOB/TEXT column 'abcdef' can't have a default value | +---------+------+------------------------------------------------------+ Posted by [name withheld] on April 27 2008 11:17am [Delete] [Edit] I struggled for some time to utilize mysql's blob column to store images and especially large files with good performance in and out. I found this tutorials implementation very useful: http://www.dreamwerx.net/phpforum/?id=1 Posted by Rajiv Kapoor on December 9 2008 9:46am [Delete] [Edit] Following way we can store blob data in a table using MYSQL: INSERT INTO PICTABLE (MYID, PIC) VALUES (3, LOAD_FILE('/PHP/ME.JPG')); Posted by Kristian Köhntopp on October 2 2009 3:19pm [Delete] [Edit] Simon Mudd is right, but there are several things that must come together to make this bad: 1. You must have a query that has an EXPLAIN which includes 'using temporary'. If 'using temporary' is shown in your EXPLAIN plan, then a temporary table is being created either in MEMORY or as MyISAM table on disk. MySQL prefers MEMORY, but there are situations where it is forced to go to disk. 2. You must have a query which includes any TEXT or BLOB type in the column list, that is in the part of the query between SELECT and FROM. The actual size of the column or its content do not matter - even a TINYTEXT that is empty is enough. Since the MEMORY storage engine cannot represent any TEXT or BLOB types at all, this forces MySQL to realize the table as an on-disk MyISAM table. How to diagnose: 1. Run show session status: kris@localhost [test_world]> show session status like 'Created_tmp%tables'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 3 | | Created_tmp_tables | 7 | +-------------------------+-------+ 2 rows in set (0.00 sec) 2. Execute the query. Make sure it is not cached: kris@localhost [test_world]> select sql_no_cache * from kris group by countrycode order by population; ... 232 rows in set (0.00 sec) 3. Check show status again: kris@localhost [test_world]> show session status like 'Created_tmp%tables'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 4 | | Created_tmp_tables | 8 | +-------------------------+-------+ 2 rows in set (0.00 sec) As you can see the Created_tmp_tables counter increased by one (in MySQL 5.0 is increases by two because the SHOW STATUS itself creates an in-memory tmp table which is being counted). If the table goes to disk as MyISAM instead of being a MEMORY Table, Created_tmp_disk_tables is also incremented by one, as seen here. This is slow. The test table I used is using the MySQL world database and mysql> create table kris as select * from City; mysql> alter table kris modify column name text; mysql> alter table kris add primary key (id); The test query shown above is 'using temporary' because I group by one column and order by another, forcing MySQL to use a temporary table. Had I been using the same query on the original City table from the world database, a tmp table would have been needed as well, but it would have been created as a MEMORY table as the original name column is a CHAR(35). So Created_tmp_tables is being bumped by one, but Created_tmp_disk_tables is not. Had I been leaving off the SQL_NO_CACHE, the query cache would have been catching repeated executions of the same query in testing and the counters would not have been moving at all except for the very first test. Posted by TM Sch on April 21 2012 8:00am [Delete] [Edit] This was my first time working with BLOB data, but I first wanted to test WITHOUT an intermediary programming language. (That would add another source of errors, I think.) I had a hard time trying to test inserting and selecting. Probably this is old had to professional programmers, but my book's limited discussion of BLOB data was about the data type, not how to use it. Newbies, to make your life easier, here's a quick how-to insert/return blob data at the command line: **** 1) Got errors about NULL value in NOT NULL column. Permissions were fixed as far as I could see (have MySQL installed as a service on Windows 7, and all users had at least read/execute permissions). I did not see any "max_allowed_packet" or "secure_file_priv" already existing in the "my.ini" file. SOLUTION: In addition to proper permissions, I need to use "/", not "\" in path to blob data (which was a picture). Note, this worked properly even for a non-relative path starting at the drive letter! :D Meanwhile, I tried moving the photo to a new directory to solve my so-called "permissions" problem, but that wasn't the problem. Truly, I was getting Error 1048 was because I needed to use forward slashes! (You will get Error 1048 if you try to insert a NULL value, or when using LOAD_FILE and it can't read it for any reason...not always permissions.) 2) After solving #1, SELECT statement seemed to confirm the picture is indeed stored in the table. However, this returned so many unreadable characters that I could not scroll back to see the complete results, and I had to wait a couple minutes until my computer stopped beeping. (Lucky for me, the system didn't crash.) SOLUTION: use the SUBSTRING() function in the SELECT statement to only return so many characters from that blob field! ** SAMPLE DATA IF YOU WANT TO TRY YOURSELF ** ** Edited, forgot to use double-backslashes in "Filename" column. ** CREATE TABLE Photos( PhotoID int unsigned not null auto_increment primary key, Filename varchar(255) not null unique, Caption varchar(255) not null, Photo longblob not null); DESCRIBE Photos; INSERT INTO Photos values ( NULL, 'D:\\mytemp\\WOC-logo.jpg', 'Walk of Champions official logo', LOAD_FILE('D:/mytemp/WOC-logo.jpg') ); SELECT PhotoID, Filename, Caption, SUBSTRING(Photo,1,20) from Photos; Add your own comment Top / Previous / Next / Up / Table of Contents Developer Zone Developer Articles Forums Bugs Worklog Planet MySQL Downloads MySQL Community Server MySQL Cluster MySQL Fabric MySQL Utilities MySQL Workbench Documentation MySQL Reference Manuals MySQL Workbench Expert Guides Topic Guides MySQL Cluster About MySQL Contact Us How to Buy Partners Job Opportunities Site Map Legal Legal Policies Your Privacy Rights Terms of Use Trademark Policy Contributor Agreement Search Terms of Use A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. The four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements. See Section 11.7, “Data Type Storage Requirements”. BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values. TEXT values are treated as nonbinary strings (character strings). They have a character set, and values are sorted and compared based on the collation of the character set. If strict SQL mode is not enabled and you assign a value to a BLOB or TEXT column that exceeds the column's maximum length, the value is truncated to fit and a warning is generated. For truncation of nonspace characters, you can cause an error to occur (rather than a warning) and suppress insertion of the value by using strict SQL mode. See Section 5.1.7, “Server SQL Modes”. Beginning with MySQL 5.0.60, truncation of excess trailing spaces from values to be inserted into TEXT columns always generates a warning, regardless of the SQL mode. For TEXT and BLOB columns, there is no padding on insert and no bytes are stripped on select. If a TEXT column is indexed, index entry comparisons are space-padded at the end. This means that, if the index requires unique values, duplicate-key errors will occur for values that differ only in the number of trailing spaces. For example, if a table contains 'a', an attempt to store 'a ' causes a duplicate-key error. This is not true for BLOB columns. In most respects, you can regard a BLOB column as a VARBINARY column that can be as large as you like. Similarly, you can regard a TEXT column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways: There is no trailing-space removal for BLOB and TEXT columns when values are stored or retrieved. Before MySQL 5.0.3, this differs from VARBINARY and VARCHAR, for which trailing spaces are removed when values are stored. On comparisons, TEXT is space extended to fit the compared object, exactly like CHAR and VARCHAR. For indexes on BLOB and TEXT columns, you must specify an index prefix length. For CHAR and VARCHAR, a prefix length is optional. See Section 8.3.4, “Column Indexes”. BLOB and TEXT columns cannot have DEFAULT values. If you use the BINARY attribute with a TEXT data type, the column is assigned the binary collation of the column character set. LONG and LONG VARCHAR map to the MEDIUMTEXT data type. This is a compatibility feature. MySQL Connector/ODBC defines BLOB values as LONGVARBINARY and TEXT values as LONGVARCHAR. Because BLOB and TEXT values can be extremely long, you might encounter some constraints in using them: Only the first max_sort_length bytes of the column are used when sorting. The default value of max_sort_length is 1024. You can make more bytes significant in sorting or grouping by increasing the value of max_sort_length at server startup or runtime. Any client can change the value of its session max_sort_length variable: mysql> SET max_sort_length = 2000; mysql> SELECT id, comment FROM t -> ORDER BY comment; Instances of BLOB or TEXT columns in the result of a query that is processed using a temporary table causes the server to use a table on disk rather than in memory because the MEMORY storage engine does not support those data types (see Section 8.4.4, “How MySQL Uses Internal Temporary Tables”). Use of disk incurs a performance penalty, so include BLOB or TEXT columns in the query result only if they are really needed. For example, avoid using SELECT *, which selects all columns. The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications buffers. You can change the message buffer size by changing the value of the max_allowed_packet variable, but you must do so for both the server and your client program. For example, both mysql and mysqldump enable you to change the client-side max_allowed_packet value. See Section 8.12.2, “Tuning Server Parameters”, Section 4.5.1, “mysql — The MySQL Command-Line Tool”, and Section 4.5.4, “mysqldump — A Database Backup Program”. You may also want to compare the packet sizes and the size of the data objects you are storing with the storage requirements, see Section 11.7, “Data Type Storage Requirements” Each BLOB or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened. In some cases, it may be desirable to store binary data such as media files in BLOB or TEXT columns. You may find MySQL's string handling functions useful for working with such data. See Section 12.5, “String Functions”. For security and other reasons, it is usually preferable to do so using application code rather than giving application users the FILE privilege. You can discuss specifics for various languages and platforms in the MySQL Forums (http://forums.mysql.com/). Previous / Next / Up / Table of Contents User Comments Posted by Volnei Puttini on June 22 2007 12:04pm [Delete] [Edit] A pratical example of how write and read images into MySQL tables, using Trolltech Qt4/C++ This example is for who reads/record images in tables using fields BLOB. First: Create a table, for example: CREATE TABLE picture ( ID INTEGER AUTO_INCREMENT, IMAGE BLOB, PRIMARY KEY (ID) ) ENGINE=InnoDB; 2) To read a image to a QByteArray QString fileName = "IMAGE.JPG"; QImage image(filaName); LBL_IMAGE->setPixmap(QPixmap::fromImage(image)); // Put image into QLabel object (optional) // load image to bytearray QByteArray ba; QFile f(fileName); if(f.open(QIODevice::ReadOnly)) { ba = f.readAll(); f.close(); } // Writing the image into table QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare( "INSERT INTO picture ( IMAGE ) VALUES (:IMAGE)" ); query.bindValue(":IMAGE", ba); query.exec(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else QSqlDatabase::database().commit(); 3) Now, recovery the field with the image int idx = 1; // The records ID to recover QSqlDatabase::database().transaction(); QSqlQuery query; query.prepare("SELECT ID, IMAGE FROM picture WHERE ID=:ID"); query.bindValue(":ID", idx); query.exec(); query.next(); if( query.lastError().isValid()) { qDebug() << query.lastError().text(); QSqlDatabase::database().rollback(); } else { QByteArray ba1 = query.value(1).toByteArray(); QPixmap pic; pic.loadFromData( ba1); // Show the image into a QLabel object LBL_IMAGE->setPixmap(pic); QSqlDatabase::database().commit(); } This example works fine and I use it frequently. Thanks. Posted by Bryce Nesbitt on April 4 2008 4:36pm [Delete] [Edit] On MS Windows the "no DEFAULT" rule is an error, while on other platforms it is often a warning. While not a bug, it's possible to get trapped by this if you write code on a lenient platform, and later run it on a strict platform: mysql> show warnings; +---------+------+------------------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------------------+ | Warning | 1101 | BLOB/TEXT column 'abcdef' can't have a default value | +---------+------+------------------------------------------------------+ Posted by [name withheld] on April 27 2008 11:17am [Delete] [Edit] I struggled for some time to utilize mysql's blob column to store images and especially large files with good performance in and out. I found this tutorials impl

How did the man become sterilized? Blow-dart through the testicle.

Whats the biggest party fowl? Murder

Q-what did the black man say before he crossed the road? A-i wanna cross the road.

Is your refrigerator running? Because your dad just hung himself

Excerpt from a local Newspaper: OMINOUS UNKNOWN KILLER IS STILL AT LARGE. After weeks of unexplained murders, the ominous unknown killer is still on the rise. After little evidence has been found, a young boy states that he survived one of the killer's attacks and bravely tells his story. "I had a bad dream and I woke up in the middle of the night," says the boy, "I saw that for some reason the window was open, even though I remember it being closed before I went to bed. I got up and shut it once more. Afterwards, I simply crawled under my covers and tried to get back to sleep. That's when I had a strange feeling, like someone was watching me. I looked up, and nearly jumped out of my bed. There, in the little ray of light, illuminating from between my curtains, were a pair of two eyes. These weren't regular eyes; they were dark, ominous eyes. They were bordered in black and... just plain out terrified me. That's when I saw his mouth. A long, horrendous smile that made every hair on my body stand up. The figure stood there, watching me. Finally, after what seemed like forever, he said it. A simple phrase, but said in a way only a mad man could speak. "He said, 'Go To Sleep.' I let out a scream, that's what sent him at me. He pulled up a knife; aiming at my heart. He jumped on top of my bed. I fought him back; I kicked, I punched, I rolled around, trying to knock him off me. That's when my dad busted in. The man threw the knife, it went into my dad's shoulder. The man probably would've finished him off, if one of the neighbors hadn't alerted the police. "They drove into the parking lot, and ran towards the door. The man turned and ran down the hallway. I heard a smash, like glass breaking. As I came out of my room, I saw the window that was pointing towards the back of my house was broken. I looked out it to see him vanish into the distance. I can tell you one thing, I will never forget that face. Those cold, evil eyes, and that psychotic smile. They will never leave my head." Police are still on the look for this man. If you see anyone that fits the description in this story, please contact your local police department. Jeff and his family had just moved into a new neighborhood. His dad had gotten a promotion at work, and they thought it would be best to live in one of those "fancy" neighborhoods. Jeff and his brother Liu couldn't complain though. A new, better house. What was not to love? As they were getting unpacked, one of their neighbors came by. "Hello," she said, "I'm Barbara; I live across the street from you. Well, I just wanted to introduce my self and to introduce my son." She turns around and calls her son over. "Billy, these are our new neighbors." Billy said hi and ran back to play in his yard. "Well," said Jeff's mom, "I'm Margaret, and this is my husband Peter, and my two sons, Jeff and Liu." They each introduced themselves, and then Barbara invited them to her son's birthday. Jeff and his brother were about to object, when their mother said that they would love to. When Jeff and his family are done packing, Jeff went up to his mom. "Mom, why would you invite us to some kid's party? If you haven't noticed, I'm not some dumb kid." "Jeff," said his mother, "We just moved here; we should show that we want to spend time with our neighbors. Now, we're going to that party, and that's final." Jeff started to talk, but stopped himself, knowing that he couldn't do anything. Whenever his mom said something, it was final. He walked up to his room and plopped down on his bed. He sat there looking at his ceiling when suddenly, he got a weird feeling. Not so much a pain, but... a weird feeling. He dismissed it as just some random feeling. He heard his mother call him down to get his stuff, and he walked down to get it. The next day, Jeff walked down stairs to get breakfast and got ready for school. As he sat there, eating his breakfast, he once again got that feeling. This time it was stronger. It gave him a slight tugging pain, but he once again dismissed it. As he and Liu finished breakfast, they walked down to the bus stop. They sat there waiting for the bus, and then, all of a sudden, some kid on a skateboard jumped over them, only inches above their laps. They both jumped back in surprise. "Hey, what the hell?" The kid landed and turned back to them. He kicked his skate board up and caught it with his hands. The kid seems to be about twelve; one year younger than Jeff. He wears a Aeropostale shirt and ripped blue jeans. "Well, well, well. It looks like we got some new meat." Suddenly, two other kids appeared. One was super skinny and the other was huge. "Well, since you're new here, I'd like to introduce ourselves, over there is Keith." Jeff and Liu looked over to the skinny kid. He had a dopey face that you would expect a sidekick to have. "And he's Troy." They looked over at the fat kid. Talk about a tub of lard. This kid looked like he hadn't exercised since he was crawling. "And I," said the first kid, "am Randy. Now, for all the kids in this neighborhood there is a small price for bus fare, if you catch my drift." Liu stood up, ready to punch the lights out of the kid's eyes when one of his friends pulled a knife on him. "Tsk, tsk, tsk, I had hoped you would be more cooperative, but it seems we must do this the hard way." The kid walked up to Liu and took his wallet out of his pocket. Jeff got that feeling again. Now, it was truly strong; a burning sensation. He stood up, but Liu gestured him to sit down. Jeff ignored him and walked up to the kid. "Listen here you little punk, give back my bro's wallet or else." Randy put the wallet in his pocket and pulled out his own knife. "Oh? And what will you do?" Just as he finished the sentence, Jeff popped the kid in the nose. As Randy reached for his face, Jeff grabbed the kid's wrist and broke it. Randy screamed and Jeff grabbed the knife from his hand. Troy and Keith rushed Jeff, but Jeff was too quick. He threw Randy to the ground. Keith lashed out at him, but Jeff ducked and stabbed him in the arm. Keith dropped his knife and fell to the ground screaming. Troy rushd him too, but Jeff didn't even need the knife. He just punched Troy straight in the stomach and Troy went down. As he fell, he puked all over. Liu could do nothing but look in amazement at Jeff. "Jeff how'd you?" that was all he said. They saw the bus coming and knew they'd be blamed for the whole thing. So they started running as fast as they could. As they ran, they looked back and saw the bus driver rushing over to Randy and the others. As Jeff and Liu made it to school, they didn't dare tell what happened. All they did was sit and listen. Liu just thought of that as his brother beating up a few kids, but Jeff knew it was more. It was something, scary. As he got that feeling he felt how powerful it was, the urge to just, hurt someone. He didn't like how it sounded, but he couldn't help feeling happy. He felt that strange feeling go away, and stay away for the entire day of school. Even as he walked home due to the whole thing near the bus stop, and how now he probably wouldn't be taking the bus anymore, he felt happy. When he got home his parents asked him how his day was, and he said, in a somewhat ominous voice, "It was a wonderful day." Next morning, he heard a knock at his front door. He walked down to find two police officers at the door, his mother looking back at him with an angry look. "Jeff, these officers tell me that you attacked three kids. That it wasn't regular fighting, and that they were stabbed. Stabbed, son!" Jeff's gaze fell to the floor, showing his mother that it was true. "Mom, they were the ones who pulled the knives on me and Liu." "Son," said one of the cops," We found three kids, two stabbed, one having a bruise on his stomach, and we have witnesses proving that you fled the scene. Now, what does that tell us?" Jeff knew it was no use. He could say him and Liu had been attacked, but then there was no proof it was not them who attacked first. They couldn't say that they weren't fleeing, because truth be told they were. So Jeff couldn't defend himself or Liu. "Son, call down your brother." Jeff couldn't do it, since it was him who beat up all the kids. "Sir, it...it was me. I was the one who beat up the kids. Liu tried to hold me back, but he couldn't stop me." The cop looked at his partner and they both nod. "Well kid, looks like a year in Juvy..." "Wait!" says Liu. They all looked up to see him holding a knife. The officers pulled their guns and locked them on Liu. "It was me, I beat up those little punks. Have the marks to prove it." He lifted up his sleeves to reveal cuts and bruises, as if he was in a struggle. "Son, just put the knife down," said the officer. Liu held up the knife and dropped it to the ground. He put his hands up and walked over to the cops. "No Liu, it was me! I did it!" Jeff had tears running down his face. "Huh, poor bro. Trying to take the blame for what I did. Well, take me away." The police led Liu out to the patrol car. "Liu, tell them it was me! Tell them! I was the one who beat up those kids!" Jeff's mother put her hands on his shoulders. "Jeff please, you don't have to lie. We know it's Liu, you can stop." Jeff watched helplessly as the cop car speeds off with Liu inside. A few minutes later Jeff's dad pulled into the driveway, seeing Jeff's face and knowing something was wrong. "Son, son what is it?" Jeff couldn't answer. His vocal cords were strained from crying. Instead, Jeff's mother walked his father inside to break the bad news to him as Jeff wept in the driveway. After an hour or so Jeff walked back in to the house, seeing that his parents were both shocked, sad, and disappointed. He couldn't look at them. He couldn't see how they thought of Liu when it was his fault. He just went to sleep, trying to get the whole thing off his mind. Two days went by, with no word from Liu at JDC. No friends to hang out with. Nothing but sadness and guilt. That is until Saturday, when Jeff is woke up by his mother, with a happy, sunshiny face. "Jeff, it's the day." she said as she opened up the curtains and let light flood into his room. "What, what's today?" asked Jeff as he stirs awake. "Why, it's Billy's party." He was now fully awake. "Mom, you're joking, right? You don't expect me to go to some kid's party after..." There was a long pause. "Jeff, we both know what happened. I think this party could be the thing that brightens up the past days. Now, get dressed." Jeff's mother walked out of the room and downstairs to get ready herself. He fought himself to get up. He picked out a random shirt and pair of jeans and walked down stairs. He saw his mother and father all dressed up; his mother in a dress and his father in a suit. He thought, why they would ever wear such fancy clothes to a kid's party? "Son, is that all your going to wear?" said Jeff's mom. "Better than wearing too much." he said. His mother pushed down the feeling to yell at him and hid it with a smile. "Now Jeff, we may be over-dressed, but this is how you go if you want to make an impression." said his father. Jeff grunted and went back up to his room. "I don't have any fancy clothes!" he yelled down stairs. "Just pick out something." called his mother. He looked around in his closet for what he would call fancy. He found a pair of black dress pants he had for special occasions and an undershirt. He couldn't find a shirt to go with it though. He looked around, and found only striped and patterned shirts. None of which go with dress pants. Finally he found a white hoodie and put it on. "You're wearing that?" they both said. His mother looked at her watch. "Oh, no time to change. Let's just go." She said as she herded Jeff and his father out the door. They crossed the street over to Barbara and Billy's house. They knocked on the door and at it appeared that Barbara, just like his parents, way over-dressed. As they walked inside all Jeff could see were adults, no kids. "The kids are out in the yard. Jeff, how about you go and meet some of them?" said Barbara. Jeff walked outside to a yard full of kids. They were running around in weird cowboy costumes and shooting each other with plastic guns. He might as well be standing in a Toys R Us. Suddenly a kid came up to him and handed him a toy gun and hat. "Hey. Wanna pway?" he said. "Ah, no kid. I'm way too old for this stuff." The kid looked at him with that weird puppydog face. "Pwease?" said the kid. "Fine," said Jeff. He put on the hat and started to pretend shoot at the kids. At first he thought it was totally ridiculous, but then he started to actually have fun. It might not have been super cool, but it was the first time he had done something that took his mind off of Liu. So he played with the kids for a while, until he heard a noise. A weird rolling noise. Then it hit him. Randy, Troy, and Keith all jumped over the fence on their skateboards. Jeff dropped the fake gun and ripped off the hat. Randy looked at Jeff with a burning hatred. "Hello, Jeff, is it?" he said. "We have some unfinished business." Jeff saw his bruised nose." I think we're even. I beat the crap out of you, and you get my brother sent to JDC." Randy got an angry look in his eyes. "Oh no, I don't go for even, I go for winning. You may have kicked our asses that one day, but not today." As he said that Randy rushed at Jeff. They both fell to the ground. Randy punched Jeff in the nose, and Jeff grabbed him by the ears and head butted him. Jeff pushed Randy off of him and both rose to their feet. Kids were screaming and parents were running out of the house. Troy and Keith both pulled guns out of their pockets. "No one interrupts or guts will fly!" they said. Randy pulled a knife on Jeff and stabbed it into his shoulder. Jeff screamed and fell to his knees. Randy started kicking him in the face. After three kicks Jeff grabs his foot and twists it, causing Randy to fall to the ground. Jeff stood up and walked towards the back door. Troy grabbed him. "Need some help?" He picks Jeff up by the back of the collar and throws him through the patio door. As Jeff tries to stand he is kicked down to the ground. Randy repeatedly starts kicking Jeff, until he starts to cough up blood. "Come on Jeff, fight me!" He picks Jeff up and throws him into the kitchen. Randy sees a bottle of vodka on the counter and smashes the glass over Jeff's head. "Fight!" He throws Jeff back into the living room. "Come on Jeff, look at me!" Jeff glances up, his face riddled with blood. "I was the one who got your brother sent to JDC! And now you're just gonna sit here and let him rot in there for a whole year! You should be ashamed!" Jeff starts to get up. "Oh, finally! you stand and fight!" Jeff is now to his feet, blood and vodka on his face. Once again he gets that strange feeling, the one in which he hasn't felt for a while. "Finally. He's up!" says Randy as he runs at Jeff. That's when it happens. Something inside Jeff snaps. His psyche is destroyed, all rational thinking is gone, all he can do, is kill. He grabs Randy and pile drives him to the ground. He gets on top of him and punches him straight in the heart. The punch causes Randy's heart to stop. As Randy gasps for breath. Jeff hammers down on him. Punch after punch, blood gushes from Randy's body, until he takes one final breath, and dies. Everyone is looking at Jeff now. The parents, the crying kids, even Troy and Keith. Although they easily break from their gaze and point their guns at Jeff. Jeff see's the guns trained on him and runs for the stairs. As he runs Troy and Keith let out fire on him, each shot missing. Jeff runs up the stairs. He hears Troy and Keith follow up behind. As they let out their final rounds of bullets Jeff ducks into the bathroom. He grabs the towel rack and rips it off the wall. Troy and Keith race in, knives ready. Troy swings his knife at Jeff, who backs away and bangs the towel rack into Troy's face. Troy goes down hard and now all that's left is Keith. He is more agile than Troy though, and ducks when Jeff swings the towel rack. He dropped the knife and grabbed Jeff by the neck. He pushed him into the wall. A thing of bleach fell down on top of him from the top shelf. It burnt both of them and they both started to scream. Jeff wiped his eyes as best as he could. He pulled back the towel rack and swung it straight into Keith's head. As he lay there, bleeding to death, he let out an ominous smile. "What's so funny?" asked Jeff. Keith pulled out a lighter and switched it on. "What's funny," he said, "Is that you're covered in bleach and alcohol." Jeff's eyes widened as Keith threw the lighter at him. As soon as the flame made contact with him, the flames ignited the alcohol in the vodka. While the alcohol burned him, the bleach bleached his skin. Jeff let out a terrible screech as he caught on fire. He tried to roll out the fire but it was no use, the alcohol had made him a walking inferno. He ran down the hall, and fell down the stairs. Everybody started screaming as they saw Jeff, now a man on fire, drop to the ground, nearly dead. The last thing Jeff saw was his mother and the other parents trying to extinguish the flame. That's when he passed out. When Jeff woke he had a cast wrapped around his face. He couldn't see anything, but he felt a cast on his shoulder, and stitches all over his body. He tried to stand up, but he realized that there was some tube in his arm, and when he tried to get up it fell out, and a nurse rushed in. "I don't think you can get out of bed just yet." she said as she put him back in his bed and re-inserted the tube. Jeff sat there, with no vision, no idea of what his surroundings were. Finally, after hours, he heard his mother. "Honey, are you okay?" she asked. Jeff couldn't answer though, his face was covered, and he was unable to speak. "Oh honey, I have great news. After all the witnesses told the police that Randy confessed of trying to attack you, they decided to let Liu go." This made Jeff almost bolt up, stopping halfway, remembering the tube coming out of his arm. "He'll be out by tomorrow, and then you two will be able to be together again." Jeff's mother hugs Jeff and says her goodbyes. The next couple of weeks were those where Jeff was visited by his family. Then came the day where his bandages were to be removed. His family were all there to see it, what he would look like. As the doctors unwrapped the bandages from Jeff's face everyone was on the edge of their seats. They waited until the last bandage holding the cover over his face was almost removed. "Let's hope for the best," said the doctor. He quickly pulls the cloth; letting the rest fall from Jeff's face. Jeff's mother screams at the sight of his face. Liu and Jeff's dad stare awe-struck at his face. "What? What happened to my face?" Jeff said. He rushed out of bed and ran to the bathroom. He looked in the mirror and saw the cause of the distress. His face. It...it's horrible. His lips were burnt to a deep shade of red. His face was turned into a pure white color, and his hair singed from brown to black. He slowly put his hand to his face. It had a sort of leathery feel to it now. He looked back at his family then back at the mirror. "Jeff," said Liu, "It's not that bad...." "Not that bad?" said Jeff," It's perfect!" His family were equally surprised. Jeff started laughing uncontrollably His parents noticed that his left eye and hand were twitching. "Uh... Jeff, are you okay?" "Okay? I've never felt more happy! Ha ha ha ha ha haaaaaa, look at me. This face goes perfectly with me!" He couldn't stop laughing. He stroked his face feeling it. Looking at it in the mirror. What caused this? Well, you may recall that when Jeff was fighting Randy something in his mind, his sanity, snapped. Now he was left as a crazy killing machine, that is, his parents didn't know. "Doctor," said Jeff's mom, "Is my son... alright, you know. In the head?" "Oh yes, this behavior is typical for patients that have taken very large amounts of pain killers. If his behavior doesn't change in a few weeks, bring him back here, and we'll give him a psychological test." "Oh thank you doctor." Jeff's mother went over to Jeff." Jeff, sweety. It's time to go." Jeff looks away from the mirror, his face still formed into a crazy smile. "Kay mommy, ha ha haaaaaaaaaaaa!" his mother took him by the shoulder and took him to get his clothes. "This is what came in," said the lady at the desk. Jeff's mom looked down to see the black dress pants and white hoodie her son wore. Now they were clean of blood and now stitched together. Jeff's mother led him to his room and made him put his clothes on. Then they left, not knowing that this was their final day of life. Later that night, Jeff's mother woke to a sound coming from the bathroom. It sounded as if someone was crying. She slowly walked over to see what it was. When she looked into the bathroom she saw a horrendous sight. Jeff had taken a knife and carved a smile into his cheeks. "Jeff, what are you doing?" asked his mother. Jeff looked over to his mother. "I couldn't keep smiling mommy. It hurt after awhile. Now, I can smile forever. Jeff's mother noticed his eyes, ringed in black. "Jeff, your eyes!" His eyes were seemingly never closing. "I couldn't see my face. I got tired and my eyes started to close. I burned out the eyelids so I could forever see myself; my new face." Jeff's mother slowly started to back away, seeing that her son was going insane. "What's wrong mommy? Aren't I beautiful? "Yes son," she said, "Yes you are. L-let me go get daddy, so he can see your face." She ran into the room and shook Jeff's dad from his sleep. "Honey, get the gun we....." She stopped as she saw Jeff in the doorway, holding a knife. "Mommy, you lied." That's the last thing they hear as Jeff rushes them with the knife, gutting both of them. His brother Liu woke up, startled by some noise. He didn't hear anything else, so he just shut his eyes and tried to go back to sleep. As he was on the border of slumber, he got the strangest feeling that someone was watching him. He looked up, before Jeff's hand covered his mouth. He slowly raised the knife ready to plunge it into Liu. Liu thrashed here and there trying to escape Jeff's grip. "Shhhhhhh," Jeff said,"Just go to sleep."

A Stoner sees a bag of chips.

What would you like to drink? A Pepsi. Is Coca-Cola okay? No.

A blonde walks into a bar. Shes now in a coma.

How do u know when someone is horny? look at there pants

A sick patient asks a doctor, "will i be able to play my guitar?" The doctor replies, "of course you will be able to". "Good because that is my only form of income", says the patient.

Anti Joke

What are Antijokes? Anti Jokes (or Anti Humor) is a type of comedy in which the uses is set up to expect a typical joke setup however the joke ends with such anticlimax that it becomes funny in its own right. The lack of punchline is the punchline.

Our Updated iOS App!

We've just released huge update to the iOS app! Now, access all your favorite text and photo sites like Anti-Joke, DIYLOL! A few things didn't make the original cut (like comments) but they'll be back soon. Best of all, the app is now FREE! Get it here.

The Anti Joke Book


NEW ANTI-JOKE BOOK!  Now that we've resolved the printing issues with our publisher, check out the BRAND SPANKING NEW Anti-Joke Book!

MOAR??

Want more? You might be interested in...