MySQL commonly used data types and field attributes

type of data

Value

  • tinyint Very small data 1 byte
  • smallint 2 bytes for the smaller data
  • mediumint Medium-sized data 3 bytes
  • int Standard integer 4 bytes are commonly used
  • bigint Larger data 8 bytes
  • float Floating point number 4 bytes
  • double Floating point 8 bytes
  • decimal String floating point financial calculation

String

  • char Fixed-size string 0~255
  • varchar Variable string 0~65535 commonly used
  • tinytext Micro text 2^8-1
  • text Text string 2^16-1 save large text

Time and date

  • date YYYY-MM-DD date format
  • time HH: mm: ss time format
  • datetime YYYY-MM-DD HH: mm: ss date and time format commonly used
  • timestampThe total number of milliseconds from the timestamp 1970.1.1 to the present
  • year years

null

  • No value, unknown
  • Do not use Null to perform operations, the result is null



Database field properties

Unsigned

  • Unsigned integer
  • Declared that the column cannot be negative

zerofill

  • 0 padding
  • Insufficient digits use 0 to fill int(3), 5 – 005

Self-increasing

  • Automatically +1 on the basis of the previous record
  • Usually used to set the unique primary key ~ index, must be an integer type
  • You can set the starting value and

Null, not Null

  • Assuming it is set to not Null, an error will be reported if the value is not filled
  • null, if the value is not filled, the default is null

default

  • Set the default value
  • sex, the default value is male, if the column value is not specified, it will be filled with the default value

Guess you like

Origin blog.csdn.net/weixin_44953227/article/details/108753074