A summary of the numeric data types follows.
The maximum legal
display width is 255, represented by an
m in the type definition forms listed below. This is just how
a number shows and doesn't relate to it's range.
ZEROFILL will fill empty spaces, where not significant
with zeros.
UNSIGNED, causes the full range of the type to be
expressed as positive numbers.
BIT [ m ]
A bit-field type. m
indicates the number of bits per valueM
is omitted.BIT
is a synonym for TINYINT(1)
.TINYINT[(M
)]
[UNSIGNED] [ZEROFILL]
A very small integer.-128
to 127
.0
to 255
.
BOOL
, BOOLEAN
synonyms
for TINYINT(1)
mysql>SELECT IF(0, 'true', 'false');
+------------------------+
| IF(0, 'true', 'false') |
+------------------------+
| false |
+------------------------+
mysql>SELECT IF(1, 'true', 'false');
+------------------------+
| IF(1, 'true', 'false') |
+------------------------+
| true |
+------------------------+
mysql>SELECT IF(2, 'true', 'false');
+------------------------+
| IF(2, 'true', 'false') |
+------------------------+
| true |
+------------------------+
Note though, the values TRUE
and FALSE
are aliases for 1
and 0.
mysql>SELECT IF(1 = TRUE, 'true', 'false');
+-------------------------------+
| IF(1 = TRUE, 'true', 'false') |
+-------------------------------+
| true |
+-------------------------------+
mysql>SELECT IF(2 = TRUE, 'true', 'false');
+-------------------------------+
| IF(2 = TRUE, 'true', 'false') |
+-------------------------------+
| false |
+-------------------------------+
mysql>SELECT IF(2 = FALSE, 'true', 'false');
+--------------------------------+
| IF(2 = FALSE, 'true', 'false') |
+--------------------------------+
| false |
+--------------------------------+
SMALLINT[(M
)][UNSIGNED][ZEROFILL]
A small integer. -32768
to 32767
. 0
to 65535
.MEDIUMINT[(M
)]
[UNSIGNED] [ZEROFILL]
A medium-sized integer. -8388608
to 8388607
. 0
to 16777215
.INT[(M
)]
[UNSIGNED] [ZEROFILL]
A normal-size integer. -2147483648
to 2147483647
. 0
to 4294967295
.INTEGER[(M
)] [UNSIGNED] [ZEROFILL]
synonym for INT
BIGINT[(M
)]
[UNSIGNED] [ZEROFILL]
A large integer.-9223372036854775808
to 9223372036854775807
. The unsigned
range is
0
to 18446744073709551615
.
FLOAT[(M
,D
)] [UNSIGNED] [ZEROFILL]
M
is the total
number of digits D
is the
number of digits following the decimal point
A small (single-precision)
floating-point number. -3.402823466E+38
to -1.175494351E-38
, 0
,
1.175494351E-38
to 3.402823466E+38
. UNSIGNED
, if specified, disallows
negative valuesDOUBLE[(M
,D
)] [UNSIGNED] [ZEROFILL]
A (double-precision) floating-point
number. -1.7976931348623157E+308
to -2.2250738585072014E-308
, 0
, and 2.2250738585072014E-308
to 1.7976931348623157E+308
. UNSIGNED
, if specified, disallows
negative values.DECIMAL[(M
[,D
])] [UNSIGNED] [ZEROFILL]
A packed “exact”
fixed-point number. M
is the total number
of digits (the precision) D
is the number of
digits after the decimal point (the scale). -
” sign M
.
D
is 0, values have
no decimal point or fractional part. M
)
for DECIMAL
is 65 D
)
is 30. D
is omitted, the
default is 0. If M
is
omitted, the default is 10.UNSIGNED
, if specified, disallows
negative values.+, -, *, /
)
with DECIMAL
columns CHAR
VARCHAR
BINARY
VARBINARY
BLOB
TEXT
ENUM
, and SET
. CHAR(24)
//
holds up to 24 characters.
The length of a CHAR
column is fixed
to the length that you
declare when you create the table, a value from 0 to 255.
When CHAR
values are stored, they are
right-padded with
spaces to fill to the specified length. On retrieval,
trailing
spaces are removed.
Values in VARCHAR
columns on the other
hand, are variable-
length strings. The length can be specified as a value from
0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and
later versions.
// The maximum column length is subject to a row size of 65,532 bytes.
VARCHAR only stores as many characters
as are needed,
plus one byte to record the length. VARCHAR doesn't pad.
// two bytes for columns that are declared
with a length longer than 255
// as of MySQL 5.0.3 trailing spaces are stored and retrieved
Exceeding column maximum length, results in a value that
is truncated to fit. If not spaces, a warning is generated.
BINARY and VARBINARY are as a pair similar to CHAR
and VARCHAR however they store binary rather than
non-binary strings. They have no character set associations.
BINARY
and VARBINARY
data types are distinct from the
CHAR BINARY
and VARCHAR BINARY
data types. In the latter BINARY
attribute does not
cause the column to BINARY type is right padded. VARBINARY has
no padding on
insert and no bytes are stripped on select.
mysql>CREATE TABLE t (c BINARY(3));
Query OK, 0 rows affected (0.01 sec)
mysql>INSERT INTO t SET c = 'a';
Query OK, 1 row affected (0.01 sec)
mysql>SELECT HEX(c), c = 'a', c = 'a\0\0' from t;
+--------+---------+-------------+
| HEX(c) | c = 'a' | c = 'a\0\0' |
+--------+---------+-------------+
| 610000 | 0 | 1 |
+--------+---------+-------------+
1 row in set (0.09 sec)
The BLOB and
TEXT Types
A BLOB
is a binary large object that
can hold a variable
amount of data. The four BLOB
types
are:
TINYBLOB
BLOB
MEDIUMBLOB
LONGBLOB
In most respects, you can regard a BLOB
column as
a VARBINARY
column that has no size
limitation. Similarly,
a TEXT column may be viewed as an unlimited VARCHAR
column.
There is no trailing-space removal for BLOB or TEXT columns.
BLOB
and TEXT
values can be extremely long, you ENUM
is a string object with a value chosen from a list of An enumeration value must be a quoted string literal; it may not
be an expression, even one that evaluates to a string value. "
-
MySQL documentation
You can create a table with an ENUM
column as follows.
Example
CREATE TABLE sizes (
name ENUM('small', 'medium', 'large')
);
However, following does not work:
CREATE TABLE sizes (
c1 ENUM('small', CONCAT('med','ium'), 'large')
);
// a string literal form must be used
ENUM
member values in table
definitions. "A SET
is a string object that can
have zero or more values,
each of which must be chosen from a list of allowed values
specified when the table is created." - MySQL Documentation
SET column
values are specified separated by commas.
Accordingly, member
values should not themselves contain
commas.
Example
A column specified as SET('one' , 'two') NOT NULL can have
any of the following values:
Values
''
'one'
'two'
'one,two'
A SET
can have a maximum of 64
different members. Trailing
spaces are automatically deleted from SET
member values in
the table definitions.
The MySQL types in this category are:
DATETIME
DATE
TIMESTAMP
TIME
YEAR
.
DATETIME, DATE & TIMESTAMP Types
These types are related are all related in that they deal
with time values.
The DATETIME
type is used when both
date and time information
is needed and is displayed in 'YYYY-MM-DD
HH:MM:SS'
format.
The supported range is '1000-01-01 00:00:00'
to
'9999-12-31 23:59:59'
.
The DATE
type supplies only a date
value without a time part.
The supported range is '1000-01-01'
to '9999-12-31'
.
You can specify DATETIME
, DATE
, and TIMESTAMP
values
using any of a common set of formats:
'YYYY-MM-DD HH:MM:SS'
or 'YY-MM-DD HH:MM:SS'
format.
A “relaxed” syntax is allowed: Any
punctuation character may be
used as the delimiter between date parts or time parts.
Example of MySQL Equivalent Forms
'98-12-31 11:30:45'
'98.12.31 11+30+45'
'98/12/31 11*30*45'
'98@12@31 11^30^45'
are equivalent. mysql>SELECT MICROSECOND('2010-12-10 14:12:09.019473');
+-------------------------------------------+
| MICROSECOND('2010-12-10 14:12:09.019473') |
+-------------------------------------------+
| 19473 |
+-------------------------------------------+
TIME
values in 'HH:MM:SS'
format'HHH:MM:SS'
format for large hours
values. TIME
values may '-838:59:59'
to '838:59:59'
." A number of formatsYEAR
is a one-byte type used for
representing years1901
2155
. As with the other temporal types
variations
The UML Stereotype Stereotypes
are one of three extensibility mechanisms in Stereotypes allow you to extend the vocabulary of the UML so that you can create new model elements, derived from existing ones, but that have specific properties that are suitable for your problem domain. They are used for classifying or marking the UML building blocks in order to introduce new building blocks that speak the language of your domain and that look like primitive, or basic, model elements. For example, when modeling a network you might need to have symbols for representing routers and hubs. By using stereotyped nodes you can make these things appear as primitive building blocks. Graphically, a stereotype is rendered as a name enclosed by guillemots, <<tablespace >>, and placed above the name of another element.
- Stereotype(UML) - Wikipedia |
Chat // table symbol |
PK Chat_ID : NUMBER FK Employee_ID : NUMBER FK Customer_ID : NUMBER active : NUMBER |
<<Check>> YesNo( ) <<PK>> PK_Chat26( ) <<FK>> FK_Chat27( ) <<FK>> FK_Chat26( ) <<Index>> TC_Chat59( ) <<Index>> TC_Chat61( ) |