String Data Types
String Data Types
The data type of a column defines what value the column can hold: integer, character,
money, date and time, binary, and so on.
Each column in a database table is required to have a name and a data type and its size.
The data type is a guideline for SQL to understand what type of data is expected inside of
each column, and it also identifies how SQL will interact with the stored data.
In MySQL there are three main data types: string, numeric, and date and time.
CHAR(size) A FIXED length string (can contain letters, numbers, and special
characters). The size parameter specifies the column length in
characters - can be from 0 to 255. Default is 1
ENUM(val1, val2, val3, ...) A string object that can have only one value, chosen from a list
of possible values. You can list up to 65535 values in an ENUM
list. If a value is inserted that is not in the list, a blank value will
be inserted.
1. CHAR Datatype:
2. Char occupies all the spaces and if space is remaining, then it fill all the blank spaces with
“space” or “white space”.
BOOL or BOOLEAN Zero is considered as false, nonzero values are considered as true.
FLOAT(size, d) A floating point number. The total number of digits is specified in size. The
number of digits after the decimal point is specified in the d parameter.
COMMANDS
1. CREATE – To create database/table
name can contain only alphabets, digits, underscore and
dollor.
Syntax: Create database/table database name/table name
Syntax: Create database if not exists database name;