当前位置:   article > 正文

MySQL与Java JDBC数据类型对照_mysql数据库 jdbc 对照

mysql数据库 jdbc 对照
 MySQL数据类型JAVA数据类型JDBC TYPE
BIGINTLongBIGINT
TINYINTByteTINYINT
SMALLINTShortSMALLINT
MEDIUMINTIntegerINTEGER
INTEGERIntegerINTEGER
INTIntegerINTEGER
FLOATFloatREAL
DOUBLEDoubleDOUBLE
DECIMALBigDecimalDECIMAL
NUMERICBigDecimalNUMERIC
CHARStringCHAR
VARCHARStringVARCHAR
TINYBLOBbyte[]BINARY
TINYTEXTStringVARCHAR
BLOBbyte[]BINARY
TEXTStringLONGVARCHAR
MEDIUMBLOBbyte[]LONGVARBINARY
MEDIUMTEXTStringLONGVARCHAR
LONGBLOBbyte[]LONGVARBINARY
LONGTEXTStringLONGVARCHAR
DATEDateDATE
TIMEDateTIME
YEARDateDATE
DATETIMEDateTIMESTAMP
TIMESTAMPDateTIMESTAMP

文件:mysql-connector-java-8.0.11.jar
类名:com.mysql.cj.MysqlType

  1. /**
  2. * DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]
  3. * A packed "exact" fixed-point number. M is the total number of digits (the precision) and D is the number of digits
  4. * after the decimal point (the scale). The decimal point and (for negative numbers) the "-" sign are not counted in M.
  5. * If D is 0, values have no decimal point or fractional part. The maximum number of digits (M) for DECIMAL is 65.
  6. * The maximum number of supported decimals (D) is 30. If D is omitted, the default is 0. If M is omitted, the default is 10.
  7. *
  8. * Protocol: FIELD_TYPE_DECIMAL = 0
  9. * Protocol: FIELD_TYPE_NEWDECIMAL = 246
  10. *
  11. * These types are synonyms for DECIMAL:
  12. * DEC[(M[,D])] [UNSIGNED] [ZEROFILL],
  13. * NUMERIC[(M[,D])] [UNSIGNED] [ZEROFILL],
  14. * FIXED[(M[,D])] [UNSIGNED] [ZEROFILL]
  15. */
  16. DECIMAL("DECIMAL", Types.DECIMAL, BigDecimal.class, MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 65L, "[(M[,D])] [UNSIGNED] [ZEROFILL]"),
  17. /**
  18. * DECIMAL[(M[,D])] UNSIGNED [ZEROFILL]
  19. *
  20. * @see MysqlType#DECIMAL
  21. */
  22. DECIMAL_UNSIGNED("DECIMAL UNSIGNED", Types.DECIMAL, BigDecimal.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 65L, "[(M[,D])] [UNSIGNED] [ZEROFILL]"),
  23. /**
  24. * TINYINT[(M)] [UNSIGNED] [ZEROFILL]
  25. * A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
  26. *
  27. * Protocol: FIELD_TYPE_TINY = 1
  28. */
  29. TINYINT("TINYINT", Types.TINYINT, Integer.class, MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 3L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  30. /**
  31. * TINYINT[(M)] UNSIGNED [ZEROFILL]
  32. *
  33. * @see MysqlType#TINYINT
  34. */
  35. TINYINT_UNSIGNED("TINYINT UNSIGNED", Types.TINYINT, Integer.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 3L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  36. /**
  37. * BOOL, BOOLEAN
  38. * These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values are considered true
  39. *
  40. * BOOLEAN is converted to TINYINT(1) during DDL execution i.e. it has the same precision=3. Thus we have to
  41. * look at full data type name and convert TINYINT to BOOLEAN (or BIT) if it has "(1)" length specification.
  42. *
  43. * Protocol: FIELD_TYPE_TINY = 1
  44. */
  45. BOOLEAN("BOOLEAN", Types.BOOLEAN, Boolean.class, 0, MysqlType.IS_NOT_DECIMAL, 3L, ""),
  46. /**
  47. * SMALLINT[(M)] [UNSIGNED] [ZEROFILL]
  48. * A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.
  49. *
  50. * Protocol: FIELD_TYPE_SHORT = 2
  51. */
  52. SMALLINT("SMALLINT", Types.SMALLINT, Integer.class, MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 5L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  53. /**
  54. * SMALLINT[(M)] UNSIGNED [ZEROFILL]
  55. *
  56. * @see MysqlType#SMALLINT
  57. */
  58. SMALLINT_UNSIGNED("SMALLINT UNSIGNED", Types.SMALLINT, Integer.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 5L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  59. /**
  60. * INT[(M)] [UNSIGNED] [ZEROFILL]
  61. * A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.
  62. *
  63. * Protocol: FIELD_TYPE_LONG = 3
  64. *
  65. * INTEGER[(M)] [UNSIGNED] [ZEROFILL] is a synonym for INT.
  66. */
  67. INT("INT", Types.INTEGER, Integer.class, MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 10L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  68. /**
  69. * INT[(M)] UNSIGNED [ZEROFILL]
  70. *
  71. * @see MysqlType#INT
  72. */
  73. INT_UNSIGNED("INT UNSIGNED", Types.INTEGER, Long.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 10L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  74. /**
  75. * FLOAT[(M,D)] [UNSIGNED] [ZEROFILL]
  76. * A small (single-precision) floating-point number. Permissible values are -3.402823466E+38 to -1.175494351E-38, 0,
  77. * and 1.175494351E-38 to 3.402823466E+38. These are the theoretical limits, based on the IEEE standard. The actual
  78. * range might be slightly smaller depending on your hardware or operating system.
  79. *
  80. * M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted,
  81. * values are stored to the limits permitted by the hardware. A single-precision floating-point number is accurate to
  82. * approximately 7 decimal places.
  83. *
  84. * Protocol: FIELD_TYPE_FLOAT = 4
  85. *
  86. * Additionally:
  87. * FLOAT(p) [UNSIGNED] [ZEROFILL]
  88. * A floating-point number. p represents the precision in bits, but MySQL uses this value only to determine whether
  89. * to use FLOAT or DOUBLE for the resulting data type. If p is from 0 to 24, the data type becomes FLOAT with no M or D values.
  90. * If p is from 25 to 53, the data type becomes DOUBLE with no M or D values. The range of the resulting column is the same as
  91. * for the single-precision FLOAT or double-precision DOUBLE data types.
  92. */
  93. FLOAT("FLOAT", Types.REAL, Float.class, MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 12L, "[(M,D)] [UNSIGNED] [ZEROFILL]"),
  94. /**
  95. * FLOAT[(M,D)] UNSIGNED [ZEROFILL]
  96. *
  97. * @see MysqlType#FLOAT
  98. */
  99. FLOAT_UNSIGNED("FLOAT UNSIGNED", Types.REAL, Float.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 12L, "[(M,D)] [UNSIGNED] [ZEROFILL]"),
  100. /**
  101. * DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL]
  102. * A normal-size (double-precision) floating-point number. Permissible values are -1.7976931348623157E+308 to
  103. * -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308. These are the theoretical limits,
  104. * based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.
  105. *
  106. * M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted,
  107. * values are stored to the limits permitted by the hardware. A double-precision floating-point number is accurate to
  108. * approximately 15 decimal places.
  109. *
  110. * Protocol: FIELD_TYPE_DOUBLE = 5
  111. *
  112. * These types are synonyms for DOUBLE:
  113. * DOUBLE PRECISION[(M,D)] [UNSIGNED] [ZEROFILL],
  114. * REAL[(M,D)] [UNSIGNED] [ZEROFILL]. Exception: If the REAL_AS_FLOAT SQL mode is enabled, REAL is a synonym for FLOAT rather than DOUBLE.
  115. */
  116. DOUBLE("DOUBLE", Types.DOUBLE, Double.class, MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 22L, "[(M,D)] [UNSIGNED] [ZEROFILL]"),
  117. /**
  118. * DOUBLE[(M,D)] UNSIGNED [ZEROFILL]
  119. *
  120. * @see MysqlType#DOUBLE
  121. */
  122. DOUBLE_UNSIGNED("DOUBLE UNSIGNED", Types.DOUBLE, Double.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 22L, "[(M,D)] [UNSIGNED] [ZEROFILL]"),
  123. /**
  124. * FIELD_TYPE_NULL = 6
  125. */
  126. NULL("NULL", Types.NULL, Object.class, 0, MysqlType.IS_NOT_DECIMAL, 0L, ""),
  127. /**
  128. * TIMESTAMP[(fsp)]
  129. * A timestamp. The range is '1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' UTC.
  130. * TIMESTAMP values are stored as the number of seconds since the epoch ('1970-01-01 00:00:00' UTC).
  131. * A TIMESTAMP cannot represent the value '1970-01-01 00:00:00' because that is equivalent to 0 seconds
  132. * from the epoch and the value 0 is reserved for representing '0000-00-00 00:00:00', the "zero" TIMESTAMP value.
  133. * An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value
  134. * of 0 signifies that there is no fractional part. If omitted, the default precision is 0.
  135. *
  136. * Protocol: FIELD_TYPE_TIMESTAMP = 7
  137. *
  138. */
  139. // TODO If MySQL server run with the MAXDB SQL mode enabled, TIMESTAMP is identical with DATETIME. If this mode is enabled at the time that a table is created, TIMESTAMP columns are created as DATETIME columns.
  140. // As a result, such columns use DATETIME display format, have the same range of values, and there is no automatic initialization or updating to the current date and time
  141. TIMESTAMP("TIMESTAMP", Types.TIMESTAMP, Timestamp.class, 0, MysqlType.IS_NOT_DECIMAL, 26L, "[(fsp)]"),
  142. /**
  143. * BIGINT[(M)] [UNSIGNED] [ZEROFILL]
  144. * A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.
  145. *
  146. * Protocol: FIELD_TYPE_LONGLONG = 8
  147. *
  148. * SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.
  149. */
  150. BIGINT("BIGINT", Types.BIGINT, Long.class, MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 19L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  151. /**
  152. * BIGINT[(M)] UNSIGNED [ZEROFILL]
  153. *
  154. * @see MysqlType#BIGINT
  155. */
  156. BIGINT_UNSIGNED("BIGINT UNSIGNED", Types.BIGINT, BigInteger.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 20L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  157. /**
  158. * MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]
  159. * A medium-sized integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.
  160. *
  161. * Protocol: FIELD_TYPE_INT24 = 9
  162. */
  163. MEDIUMINT("MEDIUMINT", Types.INTEGER, Integer.class, MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 7L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  164. /**
  165. * MEDIUMINT[(M)] UNSIGNED [ZEROFILL]
  166. *
  167. * @see MysqlType#MEDIUMINT
  168. */
  169. MEDIUMINT_UNSIGNED("MEDIUMINT UNSIGNED", Types.INTEGER, Integer.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 8L, "[(M)] [UNSIGNED] [ZEROFILL]"),
  170. /**
  171. * DATE
  172. * A date. The supported range is '1000-01-01' to '9999-12-31'. MySQL displays DATE values in 'YYYY-MM-DD' format,
  173. * but permits assignment of values to DATE columns using either strings or numbers.
  174. *
  175. * Protocol: FIELD_TYPE_DATE = 10
  176. */
  177. DATE("DATE", Types.DATE, Date.class, 0, MysqlType.IS_NOT_DECIMAL, 10L, ""),
  178. /**
  179. * TIME[(fsp)]
  180. * A time. The range is '-838:59:59.000000' to '838:59:59.000000'. MySQL displays TIME values in
  181. * 'HH:MM:SS[.fraction]' format, but permits assignment of values to TIME columns using either strings or numbers.
  182. * An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value
  183. * of 0 signifies that there is no fractional part. If omitted, the default precision is 0.
  184. *
  185. * Protocol: FIELD_TYPE_TIME = 11
  186. */
  187. TIME("TIME", Types.TIME, Time.class, 0, MysqlType.IS_NOT_DECIMAL, 16L, "[(fsp)]"),
  188. /**
  189. * DATETIME[(fsp)]
  190. * A date and time combination. The supported range is '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999'.
  191. * MySQL displays DATETIME values in 'YYYY-MM-DD HH:MM:SS[.fraction]' format, but permits assignment of values to
  192. * DATETIME columns using either strings or numbers.
  193. * An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value
  194. * of 0 signifies that there is no fractional part. If omitted, the default precision is 0.
  195. *
  196. * Protocol: FIELD_TYPE_DATETIME = 12
  197. */
  198. DATETIME("DATETIME", Types.TIMESTAMP, Timestamp.class, 0, MysqlType.IS_NOT_DECIMAL, 26L, "[(fsp)]"),
  199. /**
  200. * YEAR[(4)]
  201. * A year in four-digit format. MySQL displays YEAR values in YYYY format, but permits assignment of
  202. * values to YEAR columns using either strings or numbers. Values display as 1901 to 2155, and 0000.
  203. * Protocol: FIELD_TYPE_YEAR = 13
  204. */
  205. YEAR("YEAR", Types.DATE, Date.class, 0, MysqlType.IS_NOT_DECIMAL, 4L, "[(4)]"),
  206. /**
  207. * [NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE collation_name]
  208. * A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535.
  209. * The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among
  210. * all columns) and the character set used. For example, utf8 characters can require up to three bytes per character,
  211. * so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21,844 characters.
  212. *
  213. * MySQL stores VARCHAR values as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number
  214. * of bytes in the value. A VARCHAR column uses one length byte if values require no more than 255 bytes, two length
  215. * bytes if values may require more than 255 bytes.
  216. *
  217. * Note
  218. * MySQL 5.7 follows the standard SQL specification, and does not remove trailing spaces from VARCHAR values.
  219. *
  220. * VARCHAR is shorthand for CHARACTER VARYING. NATIONAL VARCHAR is the standard SQL way to define that a VARCHAR
  221. * column should use some predefined character set. MySQL 4.1 and up uses utf8 as this predefined character set.
  222. * NVARCHAR is shorthand for NATIONAL VARCHAR.
  223. *
  224. * Protocol: FIELD_TYPE_VARCHAR = 15
  225. * Protocol: FIELD_TYPE_VAR_STRING = 253
  226. */
  227. VARCHAR("VARCHAR", Types.VARCHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 65535L, "(M) [CHARACTER SET charset_name] [COLLATE collation_name]"),
  228. /**
  229. * VARBINARY(M)
  230. * The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than nonbinary
  231. * character strings. M represents the maximum column length in bytes.
  232. *
  233. * Protocol: FIELD_TYPE_VARCHAR = 15
  234. * Protocol: FIELD_TYPE_VAR_STRING = 253
  235. */
  236. VARBINARY("VARBINARY", Types.VARBINARY, null, 0, MysqlType.IS_NOT_DECIMAL, 65535L, "(M)"),
  237. /**
  238. * BIT[(M)]
  239. * A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.
  240. * Protocol: FIELD_TYPE_BIT = 16
  241. */
  242. BIT("BIT", Types.BIT, Boolean.class, 0, MysqlType.IS_DECIMAL, 1L, "[(M)]"), // TODO maybe precision=8 ?
  243. /**
  244. * The size of JSON documents stored in JSON columns is limited to the value of the max_allowed_packet system variable (max value 1073741824).
  245. * (While the server manipulates a JSON value internally in memory, it can be larger; the limit applies when the server stores it.)
  246. *
  247. * Protocol: FIELD_TYPE_BIT = 245
  248. */
  249. JSON("JSON", Types.LONGVARCHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 1073741824L, ""),
  250. /**
  251. * ENUM('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name]
  252. * An enumeration. A string object that can have only one value, chosen from the list of values 'value1',
  253. * 'value2', ..., NULL or the special '' error value. ENUM values are represented internally as integers.
  254. * An ENUM column can have a maximum of 65,535 distinct elements. (The practical limit is less than 3000.)
  255. * A table can have no more than 255 unique element list definitions among its ENUM and SET columns considered as a group
  256. *
  257. * Protocol: FIELD_TYPE_ENUM = 247
  258. */
  259. ENUM("ENUM", Types.CHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 65535L, "('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name]"),
  260. /**
  261. * SET('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name]
  262. * A set. A string object that can have zero or more values, each of which must be chosen from the list
  263. * of values 'value1', 'value2', ... SET values are represented internally as integers.
  264. * A SET column can have a maximum of 64 distinct members. A table can have no more than 255 unique
  265. * element list definitions among its ENUM and SET columns considered as a group
  266. *
  267. * Protocol: FIELD_TYPE_SET = 248
  268. */
  269. SET("SET", Types.CHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 64L, "('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name]"),
  270. /**
  271. * TINYBLOB
  272. * A BLOB column with a maximum length of 255 (28 ??? 1) bytes. Each TINYBLOB value is stored using a
  273. * 1-byte length prefix that indicates the number of bytes in the value.
  274. *
  275. * Protocol:FIELD_TYPE_TINY_BLOB = 249
  276. */
  277. TINYBLOB("TINYBLOB", Types.VARBINARY, null, 0, MysqlType.IS_NOT_DECIMAL, 255L, ""),
  278. /**
  279. * TINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
  280. * A TEXT column with a maximum length of 255 (28 ??? 1) characters. The effective maximum length
  281. * is less if the value contains multibyte characters. Each TINYTEXT value is stored using
  282. * a 1-byte length prefix that indicates the number of bytes in the value.
  283. *
  284. * Protocol:FIELD_TYPE_TINY_BLOB = 249
  285. */
  286. TINYTEXT("TINYTEXT", Types.VARCHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 255L, " [CHARACTER SET charset_name] [COLLATE collation_name]"),
  287. /**
  288. * MEDIUMBLOB
  289. * A BLOB column with a maximum length of 16,777,215 (224 ??? 1) bytes. Each MEDIUMBLOB value is stored
  290. * using a 3-byte length prefix that indicates the number of bytes in the value.
  291. *
  292. * Protocol: FIELD_TYPE_MEDIUM_BLOB = 250
  293. */
  294. MEDIUMBLOB("MEDIUMBLOB", Types.LONGVARBINARY, null, 0, MysqlType.IS_NOT_DECIMAL, 16777215L, ""),
  295. /**
  296. * MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
  297. * A TEXT column with a maximum length of 16,777,215 (224 ??? 1) characters. The effective maximum length
  298. * is less if the value contains multibyte characters. Each MEDIUMTEXT value is stored using a 3-byte
  299. * length prefix that indicates the number of bytes in the value.
  300. *
  301. * Protocol: FIELD_TYPE_MEDIUM_BLOB = 250
  302. */
  303. MEDIUMTEXT("MEDIUMTEXT", Types.LONGVARCHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 16777215L, " [CHARACTER SET charset_name] [COLLATE collation_name]"),
  304. /**
  305. * LONGBLOB
  306. * A BLOB column with a maximum length of 4,294,967,295 or 4GB (232 ??? 1) bytes. The effective maximum length
  307. * of LONGBLOB columns depends on the configured maximum packet size in the client/server protocol and available
  308. * memory. Each LONGBLOB value is stored using a 4-byte length prefix that indicates the number of bytes in the value.
  309. *
  310. * Protocol: FIELD_TYPE_LONG_BLOB = 251
  311. */
  312. LONGBLOB("LONGBLOB", Types.LONGVARBINARY, null, 0, MysqlType.IS_NOT_DECIMAL, 4294967295L, ""),
  313. /**
  314. * LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
  315. * A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 ??? 1) characters. The effective
  316. * maximum length is less if the value contains multibyte characters. The effective maximum length
  317. * of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol
  318. * and available memory. Each LONGTEXT value is stored using a 4-byte length prefix that indicates
  319. * the number of bytes in the value.
  320. *
  321. * Protocol: FIELD_TYPE_LONG_BLOB = 251
  322. */
  323. LONGTEXT("LONGTEXT", Types.LONGVARCHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 4294967295L, " [CHARACTER SET charset_name] [COLLATE collation_name]"),
  324. /**
  325. * BLOB[(M)]
  326. * A BLOB column with a maximum length of 65,535 (216 ??? 1) bytes. Each BLOB value is stored using
  327. * a 2-byte length prefix that indicates the number of bytes in the value.
  328. * An optional length M can be given for this type. If this is done, MySQL creates the column as
  329. * the smallest BLOB type large enough to hold values M bytes long.
  330. *
  331. * Protocol: FIELD_TYPE_BLOB = 252
  332. */
  333. BLOB("BLOB", Types.LONGVARBINARY, null, 0, MysqlType.IS_NOT_DECIMAL, 65535L, "[(M)]"),
  334. /**
  335. * TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]
  336. * A TEXT column with a maximum length of 65,535 (216 ??? 1) characters. The effective maximum length
  337. * is less if the value contains multibyte characters. Each TEXT value is stored using a 2-byte length
  338. * prefix that indicates the number of bytes in the value.
  339. * An optional length M can be given for this type. If this is done, MySQL creates the column as
  340. * the smallest TEXT type large enough to hold values M characters long.
  341. *
  342. * Protocol: FIELD_TYPE_BLOB = 252
  343. */
  344. TEXT("TEXT", Types.LONGVARCHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 65535L, "[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]"),
  345. /**
  346. * [NATIONAL] CHAR[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]
  347. * A fixed-length string that is always right-padded with spaces to the specified length when stored.
  348. * M represents the column length in characters. The range of M is 0 to 255. If M is omitted, the length is 1.
  349. * Note
  350. * Trailing spaces are removed when CHAR values are retrieved unless the PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled.
  351. * CHAR is shorthand for CHARACTER. NATIONAL CHAR (or its equivalent short form, NCHAR) is the standard SQL way
  352. * to define that a CHAR column should use some predefined character set. MySQL 4.1 and up uses utf8
  353. * as this predefined character set.
  354. *
  355. * MySQL permits you to create a column of type CHAR(0). This is useful primarily when you have to be compliant
  356. * with old applications that depend on the existence of a column but that do not actually use its value.
  357. * CHAR(0) is also quite nice when you need a column that can take only two values: A column that is defined
  358. * as CHAR(0) NULL occupies only one bit and can take only the values NULL and '' (the empty string).
  359. *
  360. * Protocol: FIELD_TYPE_STRING = 254
  361. */
  362. CHAR("CHAR", Types.CHAR, String.class, 0, MysqlType.IS_NOT_DECIMAL, 255L, "[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]"),
  363. /**
  364. * BINARY(M)
  365. * The BINARY type is similar to the CHAR type, but stores binary byte strings rather than nonbinary character strings.
  366. * M represents the column length in bytes.
  367. *
  368. * The CHAR BYTE data type is an alias for the BINARY data type.
  369. *
  370. * Protocol: no concrete type on the wire TODO: really?
  371. */
  372. BINARY("BINARY", Types.BINARY, null, 0, MysqlType.IS_NOT_DECIMAL, 255L, "(M)"),
  373. /**
  374. * Top class for Spatial Data Types
  375. *
  376. * Protocol: FIELD_TYPE_GEOMETRY = 255
  377. */
  378. GEOMETRY("GEOMETRY", Types.BINARY, null, 0, MysqlType.IS_NOT_DECIMAL, 65535L, ""), // TODO check precision, it isn't well documented, only mentioned that WKB format is represented by BLOB
  379. /**
  380. * Fall-back type for those MySQL data types which c/J can't recognize.
  381. * Handled the same as BLOB.
  382. *
  383. * Has no protocol ID.
  384. */
  385. UNKNOWN("UNKNOWN", Types.OTHER, null, 0, MysqlType.IS_NOT_DECIMAL, 65535L, "");
  386. /**
  387. * Get MysqlType matching the full MySQL type name, for example "DECIMAL(5,3) UNSIGNED ZEROFILL".
  388. * Distinct *_UNSIGNED type will be returned if "UNSIGNED" is present in fullMysqlTypeName.
  389. *
  390. * @param fullMysqlTypeName
  391. * full MySQL type name
  392. * @return MysqlType
  393. */

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/688353
推荐阅读
相关标签
  

闽ICP备14008679号