Mysql Core Data Types

For those who do not know what Mysql is, we are reporting that this is a very effective system with which you can manage large amounts of data. It is free and is offered to users under a general license. At the dawn of the development of computer technology, information was β€œstored” in separate files, and then extracted from them as needed. Today, such systems are not always effective, because It takes a lot of time and labor. The Mysql program allows you to sort information and perform operations with data arrays using a very compact command code.

mysql data types

In order for the database to work correctly, in Mysql there is a concept of data type. In total, several data options are distinguished:

- VAR (n) or VARCHAR (n) - character, where n is the number of bytes that can be used (VARCHAR stores no more than 255 characters);

- mysql string data types, including the following formats: TEXT (n) - where n can be up to 65535, TINITEXT (n) - where n can be up to 255, MEDIUMTEXT (n) from n to 16 777 215 and LONGTEXT ( n) with the variable n, which can reach 4,294,967,295 (the variable TEXT differs from VARCHAR in that the first n characters are indexed for TEXT (n));

- VARBINARY or BINARY - for storing images in binary code ;

- Mysql BLOB (n) data types that have the same dimension and β€œprefixes” as TEXT (TINY-, MEDIUM-, LONGBLOB) are used for storing blobs with a case-sensitive character; for example, MEDIUMBLOB (n) has a dimension n of 16,777,215;

data type concept

- data types for time and date, including: DATE - date in year-month-date format, TIME - time in hour-minute-second format, YEAR - years from 1901 to 2155 and year 0000, DATETIME - combines DATE and TIME (the last data type is displayed in the format year-month-date-hour-minute-second); there are also Mysql data types in TIMESTAMP format, which allows you to enter years from 1970 to 2037 into the database (this is due to the assumption of the creators of the system that Mysql will be completely out of date by 2037);

- numeric, which in their composition have integer data types, including - INT - an integer from about 2.1 billion to minus 2.1 billion, TINYINT - a number from 128 to -127 or from 255 to 0, SMALINT - from 32 768 to - 32 767, BIGINT - from 9 x 10 in the eighteenth degree to -9 x 10 in the eighteenth degree, MEDIUMINT - from 8.388 million to -8.388 million (if you specify a number higher in one or another data type maximum set value, it will be truncated to allowable values).

There are also types for fractional numbers - FLOAT is a floating-point number, DOUBLE and REAL is a double density floating-point number, NUMERIC and DECIMAL is a fractional number stored as a string. In programming, FLOAT and INT are mainly used, which support the optimal speed of the base.

integer data types

Work with databases is carried out through the tool PHPMyAdmin, which comes free in the Denver package. With it, you can create a database by specifying the names of the database and various tables, data types, passwords. After that, the database is filled with information, you can create queries in the form of a search (SELECT), change (CHANGE, RENAME, MODIFY), delete (DELETE), add (ADD) or sort existing data and display certain parameters on the screen. Mysql data types in this case should be added very carefully so that programs do not produce errors. For example, you can specify a type for VARCHAR data that allows a maximum of 255 characters to be entered in the text database. And when filling the base, the text will be larger, which will lead to the fact that Mysql "truncates" the text to an acceptable length.

Source: https://habr.com/ru/post/A9659/


All Articles