Operations and Functions for Bit Strings

Describes operations and functions for bit strings, sequences of bit values, 0 and 1.

A bit string is a sequence of bits, each having the value of 0 or 1.

Operations involving bit strings are:

Examples of bit strings tested on MySQL only, BitStringOps.sql:

-- BitStringOps.sql
-- Copyright (c) 1999 HerongYang.com. All Rights Reserved.
--
SELECT BINARY('Hello'); -- BINARY() is not part of SQL-92
SELECT BINARY(X'41424344');
-- SELECT CONCAT(X'4',X'1'); -- X'..' takes double hex digits only
-- SELECT SUBSTRING(BINARY(X'41424344'),16,32); -- Not at bit level
SELECT LENGTH('Hello');
SELECT BIT_LENGTH('Hello');
SELECT 'xyz ' = 'XYZ';
SELECT BINARY('xyz') = BINARY('XYZ');

Run BitStringOps.sql on MySQL 8.0 server, you will get:

herong> %mysql%\bin\mysql --user=root --password=TopSecret test \
   < BitStringOps.sql

BINARY('Hello')
Hello
BINARY(X'41424344')
ABCD
SUBSTRING(BINARY(X'41424344'),16,32)

LENGTH('Hello')
5
BIT_LENGTH('Hello')
40
'xyz ' = 'XYZ'
1
BINARY('xyz') = BINARY('XYZ')
0

A number of interesting things to note here:

Table of Contents

 About This Book

 Introduction of SQL

 MySQL Introduction and Installation

 Introduction of MySQL Programs

 PHP Programs and MySQL Server

 Perl Programs and MySQL Servers

 Java Programs and MySQL Servers

 Datatypes and Data Literals

 Operations and Expressions

Character Strings and Bit Strings

 Operations and Functions for Character Strings

Operations and Functions for Bit Strings

 Commonly Used Functions

 Table Column Types for Different Types of Values

 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

 Locks Used in MySQL

 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures

 System, User-Defined and Stored Procedure Variables

 MySQL Server Administration

 Storage Engines in MySQL Server

 InnoDB Storage Engine - Primary and Secondary Indexes

 Performance Tuning and Optimization

 Bulk Changes on Large Tables

 MySQL Server on macOS

 Installing MySQL Server on Linux

 Connection, Performance and Second Instance on Linux

 Archived Tutorials

 References

 Full Version in PDF/EPUB