PHP mobile internet development notes (6) -- MySQL database basic review [1] _ PHP Tutorial

Source: Internet
Author: User
PHP mobile internet development notes (6)-MySQL database basic review [1]. I. data type 1. storage space of integer data types Description Value range: TINYINT1 integer with a very small byte signed value:-128 ~ 127 unsigned value: 0 ~ 1. smaller 255SMALLINT2 bytes

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


Example 1: an integer data type storage space. the value range is TINYINT. an integer with a small value of 1 byte. the value range is-128 ~ 127 unsigned value: 0 ~ 255 SMALLINT 2 byte smaller...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.