Archives

You are currently viewing archive for July 2007
Category: Study
Posted by: hajime osako
Integer Data Types
TINYINT   1 byte
SMALLINT  2 bytes
MEDIUMINT 3 bytes
INT       4 bytes
BIGINT    8 bytes
INT(4)
The number 4 is the display width which is unrelated to the range of the data type.
Values shorter than the display width are padded with spaces as necessary.
It won't cause output truncation.
INT(4) column does not require half as much storage per value at INT(8). All INT data type require 4 bytes.
No display width is specified, MySQL use the width of the full range of values for the type. Ex: SMALLINT is 6 because the widest is -32768.


Floating-Point Data Types
FLOAT and DOUBLE may be used to represent approximate-value numbers in the native binary floating-point format used by the server host's CPU.
FLOAT  4 bytes
DOUBLE 8 bytes
You can specify explicit precision and scale, but if you don't, MySQL uses the maximum accuracy allowed by the hardware. Floating-point values are stored using mantissa/exponent representation.

Fixed-Point Data Types (DECIMAL)
The defaults for omitted precision and scale are 10 and 0.
The amount of storage required for DECIMAL is approximately four bytes are required per nine digits on each side of the decimal point.

The BIT Data Type
BIT(n) column presents the range of value 0 to 2n -1, and the storage requirement is approximately INT((n+7/8) bytes per value.
To wirete literal bit values, the leteral-value notation b'xxx' can be used. For example, b'1111' equals 15.
Category: Study
Posted by: hajime osako
MySQL Query Browser

The result area tab is splittable horizontally or vertically. The Script Editor provides debugging options such as single-stepping and breakpoints.
Double-clicking a table name enters SELECT statement automatically.
Queries in the bookmark or history browser is draggable. Double-clicking a query also enters it into the query area. Most of the option settings are shared between Query Browser and Administrator.
Passwords can be save as plain text or in 'obscured' format.

MySQL Client Interfaces

MySQL Connector/ODBC, /J and /NET
/ODBC is written by C and /J and /NET are written by native language, which support for MySQL capabilities such as server-side prepared statements, stored routines and Unicode.
Category: Study
Posted by: hajime osako
Excute SQL from shell
shell> mysql -e (or --excute) "SELECT DATABASE(); SELECT VERSION();"

Statement Terminators
\c to cancel current statement
\q to exit mysql comand console
\g is terminator
\G is terminator plus output vertically

Using Script Files
mysql> SOURCE input_file
shell> mysql de_name < input_file

Output Formats
--batch (or -B) tab-delimited output
--table (or -t) tabular output
--html (or -H)  HTML format
--xml (or -X)   XML format

Clinet Commands and SQL statements
mysql> STATUS;
mysql> HELP item;
Category: Study
Posted by: hajime osako
ANSI_QUOTES
The double quote character is interpreted as an identifier-quoting character.
IGNORE_SPACE
Ignore spaces after function names.
ERROR_FOR_DIVISION_BY_ZERO
The default is that MySQL returns NULL rather than a warning (or an error in strict mode.)
STRICT_TRANS_TABLES, STRICT_ALL_TABLES
Switching on 'strict mode.' STRICT_TRANS_TABLES is only for transactional tables.
TRADITIONAL
strict modes plus several additional restrictions.
ANSI
enables behaviors are more like ANSI SQL (ex. ANSI_QUOTES, PIPES_AS_CONCAT)
*SHOW WARNINGS shows MySQL warnings.
Category: Study
Posted by: hajime osako
--protocol [ tcp | socket | pipe | memory ]
--host=host_name or -h host_name (default: localhost)
--port=port_number or -P port_number (default: 3306)
--shared-memory-base-name=memory_name (default: MYSQL)
--socket=socket_name or -S socket_name (default: /tmp/mysql.sock)
--user=user_name or -u user_name
--password=pass_value or -ppass_value or -p
--compress or -C

How to import option file:
shell: mysql --defaults-file=file_path
other options: --defaults-extra-file, --no-defaults
Category: Study
Posted by: hajime osako

Column 'Key' has three value: PRI, UNI and MUL. Even this Key is null, still this column could be the part of index as a secondary column.

MUL indicates the first column of a non-unique index or a unique value index that can contain NULL.