MySQL Tutorials - Herong's Tutorial Examples - v4.46, by Herong Yang
Table Column Types for Byte Strings
Describes 2 types of table columns to store Byte strings: BINARY and VARBINARY.
There are 2 types of table columns to store byte strings: BINARY and VARBINARY.
"BINARY(length)" - Byte string with fixed length counted in bytes.
"VARBINARY(length)" - Byte string with varying length counted in bytes.
Examples of byte string column types, ByteStringColumns.sql:
-- ByteStringColumns.sql -- Copyright (c) 1999 HerongYang.com. All Rights Reserved. -- CREATE TABLE ByteString ( Line VARCHAR(2), A BINARY(4), B CHAR(4) ); INSERT INTO ByteString VALUES ( '1', 'AAA', 'AAA' ); INSERT INTO ByteString VALUES ( '2', X'424242', X'424242' ); INSERT INTO ByteString VALUES ( '3', BINARY(X'434343'), BINARY(X'434343') ); SELECT * FROM ByteString; DROP TABLE ByteString;
Running ByteStringColumns.sql on MySQL 8.0 server gives you:
herong> %mysql%\bin\mysql --user=root --password=TopSecret test \ < ByteStringColumns.sql Line A B 1 \0AAA AAA 2 \0BBB BBB 3 \0CCC CCC
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