First, the database definition
Database system
databsesystem= Database management System (DBMS,DATEBASEMANANGEMENTSYSTEM) + database + Administrator
Dbs=dbms+db
Definition: An efficient solution for managing large amounts of information, the library for organizing, storing, and managing data in accordance with its data structure
relational database system (the corresponding non-relational database, NoSQL, such as Redis)
A database system built on a relational model,
Relational Model:
How the entity structure should be handled when the entity (student) in daily life, and the attribute of the entity (student's number, name) are saved to the database
1, the data structure can be stipulated, the same kind of information, structure consistent, is a two-dimensional table,
2, the relationship between the data can be set, the connection between entities
SQL: Database management system, language for managing data, Structured Query Language (sql,structuredquerylanguage)
MySQL is the C/S model, client/server, Client/sever (client, server side, database)
View character Set show variables like '%char% ';
Show variables (display character set)
ii. types of SQL databases
Use unsigned to control whether there are positive or negative
You can use Zerofill to make a leading fill
There is also a Boolean bool type, but it is the alias of tinyint (1)
tinyint
1 bytes
-128-127
0-255
When defined, unsigned is a signed
Define display width: To achieve uniform display by defining the display width of the data
Type (m) m indicates the minimum width of the display,
Need to use a leading zero fill to achieve the purpose, called Zerofill
Example: ALTER TABLE XXX add c tinyint (2) Zerofill; (Display width is 2)
Note: 1, does not affect the number of the range 2, the width of the large without impact, will not intercept
Type byte minimum (signed/unsigned) maximum (signed/unsigned)
tinyint 1-128/0 127/255
smallint 2-32768/0 32767/65535
Mediumint 3-8388608/0 8388607/16777215
Int/intege 4-2147483648/0 2147483647/4294967295
BigInt 8
Float (single precision) 4 (the default precision bit is about 6 bits)
Double (doubles) 8 (default is about 16 bits)
Supported, controlling the range of numeric values type (M,D) M for the number of digits (excluding decimal points and symbols) D means the number of decimal places allowed
A float (5,2)
999.99-999.99
b Double (8,3)
-99999.999 99999.999
Floating-point support scientific notation 1.1234E3 equivalent to 1.1234*1000
Fixed-point number: Decimal (m,d) m total digit D small digit m default is 10, default is 0
Date Time
Date and time, seconds and seconds
Datatime Timestamp Data Time Year
Time Type: Indicates the meaning: 1, the Day of the Year 2, indicates the time interval
String type
Type Maximum length
Char 255
varchar 65535 (entire record length + Save as null (for one byte) + Keep record length information (2 bytes))
Text does not specify a length, is similar to varchar, and does not have to hold the length information, can completely keep the information
Enum (enum type) example gender enum (' Female ', ' male ');
Set (' Basket ', ' football ', ' Pingpang ');
Insert into XX value (' Basket,football ');
MySQL Database Introduction and application