Great field definitions are fundamental for the advancement of your information base. The ideal methodology necessitates that you solely utilize a field of the sort and size required. For instance, on the off chance that you will just utilize a field, five-characters wide, don't characterize a field, 20-characters wide. Field (or section) types are otherwise called information types given the information types put away inside the field.
MariaDB information types can be sorted as numeric, date and time, and string esteems.
Numeric Data Types
The numeric information types upheld by MariaDB are as per the following −
- TINYINT − This information type addresses little numbers falling inside the marked scope of - 128 to 127, and the unsigned scope of 0 to 255.
- BOOLEAN − This information type connects a worth 0 with "bogus," and a worth 1 with "valid."
- SMALLINT − This information type addresses whole numbers inside the marked scope of - 32768 to 32768, and the unsigned scope of 0 to 65535.
- MEDIUMINT − This information type addresses whole numbers in the marked scope of - 8388608 to 8388607, and the unsigned scope of 0 to 16777215.
- INT(also INTEGER) − This information type addresses a number of ordinary size. At the point when set apart as unsigned, the reach traverses 0 to 4294967295. At the point when marked (the default setting), the reach ranges - 2147483648 to 2147483647. At the point when a segment is set to ZEROFILL( an unsigned express), every one of its qualities are prepended by zeros to put M digits in the INT esteem.
- BIGINT − This information type addresses whole numbers inside the marked scope of 9223372036854775808 to 9223372036854775807, and the unsigned scope of 0 to 18446744073709551615.
- DECIMAL( likewise DEC, NUMERIC, FIXED)− This information type addresses exact fixed-point numbers, with M determining its digits and D indicating the digits after the decimal. The M worth doesn't add "- " or the decimal point. In the event that D is set to 0, no decimal or division part shows up and the worth will be adjusted to the closest DECIMAL on INSERT. The greatest allowed digits is 65, and the most extreme for decimals is 30. Default an incentive for M on oversight is 10, and 0 for D on exclusion.
- Buoy − This information type addresses a little, skimming point number of the worth 0 or a number inside the accompanying reaches −
- - 3.402823466E+38 to - 1.175494351E-38
- 1.175494351E-38 to 3.402823466E+38
- Twofold (likewise REAL and DOUBLE PRECISION) − This information type addresses ordinary size, skimming point quantities of the worth 0 or inside the accompanying reaches −
- - 1.7976931348623157E+308 to - 2.2250738585072014E-308
- 2.2250738585072014E-308 to 1.7976931348623157E+308
- Touch − This information type addresses bit fields with M determining the quantity of pieces per esteem. On exclusion of M, the default is 1. Touch esteems can be applied with " b'[value]'" in which worth addresses bit an incentive in 0s and 1s. Zero-cushioning happens consequently from the left for full length; for instance, "10" becomes "0010."
Date and Time Data Types
The date and time information types upheld by MariaDB are as per the following −
- DATE − This information type addresses a date scope of "1000-01-01" to "9999-12-31," and utilizes the "YYYY-MM-DD" date design.
- TIME − This information type addresses a period scope of "- 838:59:59.999999" to "838:59:59.999999."
- DATETIME − This information type addresses the reach "1000-01-01 00:00:00.000000" to "9999-12-31 23:59:59.999999." It utilizes the "YYYY-MM-DD HH:MM:SS" design.
- TIMESTAMP − This information type addresses a timestamp of the "YYYY-MM-DD HH:MM:DD" design. It essentially discovers use in enumerating the hour of information base adjustments, e.g., addition or update.
- YEAR − This information type addresses a year in 4-digit design. The four-digit design permits esteems in the scope of 1901 to 2155, and 0000.
String DataTypes
The string type esteems upheld by MariaDB are as per the following −
- String literals − This information type addresses character groupings encased by cites.
- Char − This information type addresses a right-cushioned, fixed-length string containing spaces of indicated length. M addresses section length of characters in a scope of 0 to 255, its default esteem is 1.
- VARCHAR − This information type addresses a variable-length string, with a M reach (most extreme section length) of 0 to 65535.
- Double − This information type addresses paired byte strings, with M as the segment length in bytes.
- VARBINARY − This information type addresses parallel byte strings of variable length, with M as section length.
- TINYBLOB − This information type addresses a mass section with a most extreme length of 255 (28 - 1) bytes. Away, each utilizations a one-byte length prefix demonstrating the byte amount in the worth.
- Mass − This information type addresses a mass segment with a most extreme length of 65,535 (216 - 1) bytes. Away, each utilizations a two-byte length prefix demonstrating the byte amount in the worth.
- MEDIUMBLOB − This information type addresses a mass segment with a most extreme length of 16,777,215 (224 - 1) bytes. Away, each utilizations a three-byte length prefix demonstrating the byte amount in the worth.
- LONGBLOB − This information type addresses a mass segment with a greatest length of 4,294,967,295(232 - 1) bytes. Away, each utilizations a four-byte length prefix demonstrating the byte amount in the worth.
- TINYTEXT − This information type addresses a book segment with a most extreme length of 255 (28 - 1) characters. Away, each utilizations a one-byte length prefix demonstrating the byte amount in the worth.
- TEXT − This information type addresses a book segment with a most extreme length of 65,535 (216 - 1) characters. Away, each utilizations a two-byte length prefix showing the byte amount in the worth.
- MEDIUMTEXT − This information type addresses a book section with a greatest length of 16,777,215 (224 - 1) characters. Away, each utilizations a three-byte length prefix showing the byte amount in the worth.
- LONGTEXT − This information type addresses a book segment with a most extreme length of 4,294,967,295 or 4GB (232 - 1) characters. Away, each utilizations a four-byte length prefix showing the byte amount in the worth.
- ENUM − This information type addresses a string object having just a solitary incentive from a rundown.
- SET − This information type addresses a string object having at least zero qualities from a rundown, with a limit of 64 individuals. SET qualities present inside as whole number qualities.