PHP mobile internet development notes (6) -- MySQL database basic review recently read some architecture materials, but found that the basic knowledge is not very strong. for the next time, I will summarize the basic knowledge on a regular basis.
I. Data types
1. integer
Data type |
Storage space |
Description |
Value range |
TINYINT |
1 byte |
Very small integer |
Signed value:-128 ~ 127 Unsigned value: 0 ~ 255 |
SMALLINT |
2 bytes |
Small integer |
Signed value:-32768 ~ 32767 Unsigned value: 0 ~ 65535 |
MEDIUMNT |
3 bytes |
An integer of medium size |
Signed value:-8388608 ~ 8388607 Unsigned value: 0 ~ 16777215 |
INT |
4 bytes |
Standard integer |
Signed value:-2147483648 ~ 2147483647 Unsigned value: 0 ~ 4294967295 |
BIGINT |
8 bytes |
Big integer |
2. Floating point
Data type |
Storage space |
Description |
Value range |
FLOAT |
4 bytes |
But the precision floating point number |
DOUBLE |
8 bytes |
Double-precision floating point number |
DECIMAL (M, D) |
Custom |
In string format |
3. string type
Type |
Storage space |
Description |
Maximum length |
Char [(M)] |
MB bytes |
Fixed length string |
MB bytes |
Varchar [(M)] |
L + 1 byte |
Variable length string |
MB bytes |
Tinyblog, tingtext |
L + 1 byte |
Very small blob and text string |
2 ^ 8 characters |
Blog, text |
L + 2 bytes |
Small BLOB and text string |
2 ^ 16-1 bytes |
Mediumblob, mediumtext |
L + 3 bytes |
Moderate BLOB and text string |
2 ^ 24 bytes |
Longblob, longtext |
L + 4 bytes |
Large BLOB and text string |
2 ^ 32-1 bytes |
Enum ('value', 'value ') |
1 or 2 bytes |
Enumeration: you can assign an enumeration member. |
65535 members |
Set ('value', 'value ') |
1, 2, 3, 4, or 8 bytes |
Set: you can assign multiple set members. |
64 members |
4. date and time data
Type |
Storage space |
Description |
Maximum length |
Date |
3 bytes |
YYYY-MM-DD format representation |
1000-01-01 ~ 9999-12-31 |
TIME |
3 bytes |
Hh: mm: ss format indicates the time value |
-838: 59: 59 ~ 838: 59: 59 |
DATETIME |
8 bytes |
YYYY-MM-DD hh: mm: ss format |
TIMESTAMP |
4 bytes |
The format of YYYYMMDDhhmmss indicates the timestamp. |
YEAR |
1 byte |
Year value in YYYY format |
1901 ~ 2155 |
II. MySQL database operations
1. log on to the database
Mysql parameters
-D, -- database = name: Open the specified database
-- Delimiter = name specifies the delimiter
-E, -- vertical display result
-H, -- host = name server name
-H, -- html provides HTML output
-X, -- xml provides XML output
-P, -- password [= name] password
-P, -- port = # port number
-- Prompt = name: Set the prompt
-U, -- user = name username
-V, -- version: Output version information and exit
Mysql-h server host address-u user name-p user password
2. log out
Exit
Quit
/Q
3. change the password
4. create, select, and view databases
Create a database
Select database
Delete database content