Home  >  Article  >  What type is used for bank card numbers in mysql?

What type is used for bank card numbers in mysql?

百草
百草Original
2023-06-14 16:34:541635browse

The bank card number in mysql uses the "varchar" string type. Because the bank card number is long and all digits, for the convenience of storage, it is stored in a unified string type. If the "number" type is used, it will exceed the maximum value range of the "int" type and must be stored in "bigInteger", which is not conducive to the normal conversion of data.

What type is used for bank card numbers in mysql?

The operating system of this tutorial: Windows 10 system, mysql version 8.0, Dell G3 computer.

The bank card number is stored in the string type, which is the "varchar" type. Because bank card numbers are long and all are numbers, for the convenience of storage, they are stored in a unified string type. If it is stored as number type, it has exceeded the maximum value range of int type and must be stored with bigInteger, which is very inconvenient. And values ​​with too many digits will become scientific notation, which is not conducive to normal conversion of data, so it is more convenient to store them in string type.

Data type (data_type) refers to the type of data allowed in the system. Each column in the database should have an appropriate data type that limits or allows the data stored in that column. For example, if the column stores numbers, the corresponding data type should be numeric.

If you use the wrong data type, it may seriously affect the function and performance of the application. Therefore, when designing the table, you should pay special attention to the data type used in the data column. Changing a column containing data is not a trivial matter, and doing so may result in data loss. Therefore, the correct data type and length must be set for each column when creating the table.

The data types of MySQL can be roughly divided into integer types, floating-point and fixed-point types, date and time types, string types, binary types, etc.

Note: Integer types and floating point types can be collectively referred to as numeric data types.

  1. Numeric types: Integer types include TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT, floating-point types include FLOAT and DOUBLE, and fixed-point types are DECIMAL.

  2. Date/time types: including YEAR, TIME, DATE, DATETIME and TIMESTAMP.

  3. String types: including CHAR, VARCHAR, BINARY, VARBINARY, BLOB, TEXT, ENUM and SET, etc.

  4. Binary types: including BIT, BINARY, VARBINARY, TINYBLOB, BLOB, MEDIUMBLOB and LONGBLOB.

The above is the detailed content of What type is used for bank card numbers in mysql?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn