Data Literals

Describes how to enter data into programs as data literals for different datatypes.

Now we know the types of data, and how they are stored in memory. Next we need know how data can get in to the computer. One way is to enter it through the program source code as a data literal.

Data Literal: An program source element that represents a data value. Data literals can be divided into multiple groups depending the type of the data it is representing and how it is representing.

1. Character String Literals are used to construct character strings, exact numbers, approximate numbers and data and time values. The syntax rules of character string literals are pretty simple:

Examples of character string literals:

'Hello world!'
'Loews L''Enfant Plaza'
'123'
'0.123e-1'
'1999-01-01'

2. Hex String Literals are used to construct character strings and exact numbers. The syntax rules for hex string literals are also very simple:

Examples of hex string literals:

x'41424344'
x'31323334'
x'31323334'
x'01'
x'0001'
x'ff'
x'ffffffff'
x'ffffffffffffffff'

3. Numeric Literals are used to construct exact numbers and approximate numbers. Syntax rules of numeric literals are:

Examples of numeric literals:

1
-22
33.3
-44.44
55.555e5
-666.666e-6

4. Date and Time Literals are used to construct date and time values. The syntax of date and time literals are:

Examples of data and time literals:

DATE '1999-01-01'
TIMESTAMP '1999-01-01 01:02:03'

5. Time Interval Literals are used to construct time intervals with different time units.

Examples of time interval literals:

INTERVAL '3' YEAR
INTERVAL '1' DAY
INTERVAL '4' MONTH
INTERVAL '1' HOUR
INTERVAL '5' MINUTE
INTERVAL '9' SECOND

6. Null Literal is used to construct a null value for any data type. The syntax of null literal is the word "null".

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

 Introduction of Datatype

 Data Binary Representations

Data Literals

 Data Literal Evaluation

 Character String Literal Evaluation Examples

 Hex String Literal Evaluation Examples

 Numeric Literal Evaluation Examples

 Operations and Expressions

 Character Strings and 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