MySQLDataType

public struct MySQLDataType : SQLDataType, Equatable

MySQL table column data types.

  • bit

    A bit-value type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.

    Declaration

    Swift

    public static var bit: MySQLDataType { get }
  • A bit-value type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.

    Declaration

    Swift

    public static func bit(_ m: Int? = nil) -> MySQLDataType
  • A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.

    Declaration

    Swift

    public static var tinyint: MySQLDataType { get }
  • A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.

    Declaration

    Swift

    public static func tinyint(_ m: Int? = nil, unsigned: Bool = false, zerofill: Bool = false) -> MySQLDataType
  • These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values are considered true.

    Declaration

    Swift

    public static var bool: MySQLDataType { get }
  • A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.

    Declaration

    Swift

    public static var smallint: MySQLDataType { get }
  • A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.

    Declaration

    Swift

    public static func smallint(_ m: Int? = nil, unsigned: Bool = false, zerofill: Bool = false) -> MySQLDataType
  • A medium-sized integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.

    Declaration

    Swift

    public static var mediumint: MySQLDataType { get }
  • A medium-sized integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.

    Declaration

    Swift

    public static func mediumint(_ m: Int? = nil, unsigned: Bool = false, zerofill: Bool = false) -> MySQLDataType
  • int

    A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

    Declaration

    Swift

    public static var int: MySQLDataType { get }
  • A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

    Declaration

    Swift

    public static func int(_ m: Int? = nil, unsigned: Bool = false, zerofill: Bool = false) -> MySQLDataType
  • A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.

    Declaration

    Swift

    public static var bigint: MySQLDataType { get }
  • A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.

    Declaration

    Swift

    public static func bigint(_ m: Int? = nil, unsigned: Bool = false, zerofill: Bool = false) -> MySQLDataType
  • A packed “exact” fixed-point number. M is the total number of digits (the precision) and D is the number of digits after the decimal point (the scale). The decimal point and (for negative numbers) the - sign are not counted in M. If D is 0, values have no decimal point or fractional part. The maximum number of digits (M) for DECIMAL is 65. 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.

    Declaration

    Swift

    public static var decimal: MySQLDataType { get }
  • A packed “exact” fixed-point number. M is the total number of digits (the precision) and D is the number of digits after the decimal point (the scale). The decimal point and (for negative numbers) the - sign are not counted in M. If D is 0, values have no decimal point or fractional part. The maximum number of digits (M) for DECIMAL is 65. 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.

    Declaration

    Swift

    public static func decimal(_ md: (Int, Int?)? = nil, unsigned: Bool = false, zerofill: Bool = false) -> MySQLDataType
  • A small (single-precision) floating-point number. Permissible values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.

    Declaration

    Swift

    public static var float: MySQLDataType { get }
  • A small (single-precision) floating-point number. Permissible values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.

    Declaration

    Swift

    public static func float(_ md: (Int, Int)? = nil, unsigned: Bool = false, zerofill: Bool = false) -> MySQLDataType
  • A normal-size (double-precision) floating-point number. Permissible values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.

    Declaration

    Swift

    public static var double: MySQLDataType { get }
  • A normal-size (double-precision) floating-point number. Permissible values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.

    Declaration

    Swift

    public static func double(_ md: (Int, Int)? = nil, unsigned: Bool = false, zerofill: Bool = false) -> MySQLDataType
  • A date. The supported range is ‘1000-01-01’ to ‘9999-12-31’. MySQL displays DATE values in ‘YYYY-MM-DD’ format, but permits assignment of values to DATE columns using either strings or numbers.

    Declaration

    Swift

    public static var date: MySQLDataType { get }
  • A date and time combination. The supported range is ‘1000-01-01 00:00:00.000000’ to ‘9999-12-31 23:59:59.999999’. MySQL displays DATETIME values in ‘YYYY-MM-DD HH:MM:SS[.fraction]’ format, but permits assignment of values to DATETIME columns using either strings or numbers.

    Declaration

    Swift

    public static var datetime: MySQLDataType { get }
  • A date and time combination. The supported range is ‘1000-01-01 00:00:00.000000’ to ‘9999-12-31 23:59:59.999999’. MySQL displays DATETIME values in ‘YYYY-MM-DD HH:MM:SS[.fraction]’ format, but permits assignment of values to DATETIME columns using either strings or numbers.

    Declaration

    Swift

    public static func datetime(_ fsp: MySQLFractionalSecondsPrecision? = nil) -> MySQLDataType
  • A timestamp. The range is ‘1970-01-01 00:00:01.000000’ UTC to ‘2038-01-19 03:14:07.999999’ UTC. TIMESTAMP values are stored as the number of seconds since the epoch (‘1970-01-01 00:00:00’ UTC). A TIMESTAMP cannot represent the value ‘1970-01-01 00:00:00’ because that is equivalent to 0 seconds from the epoch and the value 0 is reserved for representing ‘0000-00-00 00:00:00’, the “zero” TIMESTAMP value.

    Declaration

    Swift

    public static var timestamp: MySQLDataType { get }
  • A timestamp. The range is ‘1970-01-01 00:00:01.000000’ UTC to ‘2038-01-19 03:14:07.999999’ UTC. TIMESTAMP values are stored as the number of seconds since the epoch (‘1970-01-01 00:00:00’ UTC). A TIMESTAMP cannot represent the value ‘1970-01-01 00:00:00’ because that is equivalent to 0 seconds from the epoch and the value 0 is reserved for representing ‘0000-00-00 00:00:00’, the “zero” TIMESTAMP value.

    Declaration

    Swift

    public static func timestamp(_ fsp: MySQLFractionalSecondsPrecision? = nil) -> MySQLDataType
  • A time. The range is ‘-838:59:59.000000’ to ‘838:59:59.000000’. MySQL displays TIME values in ‘HH:MM:SS[.fraction]’ format, but permits assignment of values to TIME columns using either strings or numbers.

    Declaration

    Swift

    public static var time: MySQLDataType { get }
  • A time. The range is ‘-838:59:59.000000’ to ‘838:59:59.000000’. MySQL displays TIME values in ‘HH:MM:SS[.fraction]’ format, but permits assignment of values to TIME columns using either strings or numbers.

    Declaration

    Swift

    public static func time(_ fsp: MySQLFractionalSecondsPrecision? = nil) -> MySQLDataType
  • A year in four-digit format. MySQL displays YEAR values in YYYY format, but permits assignment of values to YEAR columns using either strings or numbers. Values display as 1901 to 2155, and 0000.

    Declaration

    Swift

    public static var year: MySQLDataType { get }
  • A fixed-length string that is always right-padded with spaces to the specified length when stored. M represents the column length in characters. The range of M is 0 to 255. If M is omitted, the length is 1.

    Declaration

    Swift

    public static var char: MySQLDataType { get }
  • A fixed-length string that is always right-padded with spaces to the specified length when stored. M represents the column length in characters. The range of M is 0 to 255. If M is omitted, the length is 1.

    Declaration

    Swift

    public static func char(_ m: Int? = nil, characterSet: MySQLCharacterSet? = nil, collate: MySQLCollation? = nil) -> MySQLDataType
  • A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used. For example, utf8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21,844 characters.

    Declaration

    Swift

    public static var varchar: MySQLDataType { get }
  • A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used. For example, utf8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21,844 characters.

    Declaration

    Swift

    public static func varchar(_ m: Int? = nil, characterSet: MySQLCharacterSet? = nil, collate: MySQLCollation? = nil) -> MySQLDataType
  • The BINARY type is similar to the CHAR type, but stores binary byte strings rather than nonbinary character strings. An optional length M represents the column length in bytes. If omitted, M defaults to 1.

    Declaration

    Swift

    public static var binary: MySQLDataType { get }
  • The BINARY type is similar to the CHAR type, but stores binary byte strings rather than nonbinary character strings. An optional length M represents the column length in bytes. If omitted, M defaults to 1.

    Declaration

    Swift

    public static func binary(_ m: Int? = nil) -> MySQLDataType
  • The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than nonbinary character strings. M represents the maximum column length in bytes.

    Declaration

    Swift

    public static func varbinary(_ m: Int) -> MySQLDataType
  • A BLOB column with a maximum length of 255 (28 − 1) bytes. Each TINYBLOB value is stored using a 1-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static var tinyblob: MySQLDataType { get }
  • A TEXT column with a maximum length of 255 (28 − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TINYTEXT value is stored using a 1-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static var tinytext: MySQLDataType { get }
  • A TEXT column with a maximum length of 255 (28 − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TINYTEXT value is stored using a 1-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static func tinytext(characterSet: MySQLCharacterSet? = nil, collate: MySQLCollation? = nil) -> MySQLDataType
  • A BLOB column with a maximum length of 65,535 (216 − 1) bytes. Each BLOB value is stored using a 2-byte length prefix that indicates the number of bytes in the value. An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest BLOB type large enough to hold values M bytes long.

    Declaration

    Swift

    public static var blob: MySQLDataType { get }
  • A BLOB column with a maximum length of 65,535 (216 − 1) bytes. Each BLOB value is stored using a 2-byte length prefix that indicates the number of bytes in the value. An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest BLOB type large enough to hold values M bytes long.

    Declaration

    Swift

    public static func blob(_ m: Int? = nil) -> MySQLDataType
  • A TEXT column with a maximum length of 65,535 (216 − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TEXT value is stored using a 2-byte length prefix that indicates the number of bytes in the value. An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest TEXT type large enough to hold values M characters long.

    Declaration

    Swift

    public static var text: MySQLDataType { get }
  • A TEXT column with a maximum length of 65,535 (216 − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TEXT value is stored using a 2-byte length prefix that indicates the number of bytes in the value. An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest TEXT type large enough to hold values M characters long.

    Declaration

    Swift

    public static func text(_ m: Int? = nil, characterSet: MySQLCharacterSet? = nil, collate: MySQLCollation? = nil) -> MySQLDataType
  • A BLOB column with a maximum length of 16,777,215 (224 − 1) bytes. Each MEDIUMBLOB value is stored using a 3-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static var mediumblob: MySQLDataType { get }
  • A TEXT column with a maximum length of 16,777,215 (224 − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each MEDIUMTEXT value is stored using a 3-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static var mediumtext: MySQLDataType { get }
  • A TEXT column with a maximum length of 16,777,215 (224 − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each MEDIUMTEXT value is stored using a 3-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static func mediumtext(characterSet: MySQLCharacterSet? = nil, collate: MySQLCollation? = nil) -> MySQLDataType
  • A BLOB column with a maximum length of 4,294,967,295 or 4GB (232 − 1) bytes. The effective maximum length of LONGBLOB columns depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGBLOB value is stored using a 4-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static var longblob: MySQLDataType { get }
  • A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 − 1) characters. The effective maximum length is less if the value contains multibyte characters. The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGTEXT value is stored using a 4-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static var longtext: MySQLDataType { get }
  • A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 − 1) characters. The effective maximum length is less if the value contains multibyte characters. The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGTEXT value is stored using a 4-byte length prefix that indicates the number of bytes in the value.

    Declaration

    Swift

    public static func longtext(characterSet: MySQLCharacterSet? = nil, collate: MySQLCollation? = nil) -> MySQLDataType
  • MARK: Special A string object that can have only one value, chosen from the list of values ‘value1’, ‘value2’, …, NULL or the special “ error value. ENUM values are represented internally as integers. An ENUM column can have a maximum of 65,535 distinct elements. The maximum supported length of an individual ENUM element is M <= 255 and (M x w) <= 1020, where M is the element literal length and w is the number of bytes required for the maximum-length character in the character set.

    Declaration

    Swift

    public static func `enum`(_ cases: [String?], characterSet: MySQLCharacterSet? = nil, collate: MySQLCollation? = nil) -> MySQLDataType
  • A set. A string object that can have zero or more values, each of which must be chosen from the list of values ‘value1’, ‘value2’, … SET values are represented internally as integers. A SET column can have a maximum of 64 distinct members. The maximum supported length of an individual SET element is M <= 255 and (M x w) <= 1020, where M is the element literal length and w is the number of bytes required for the maximum-length character in the character set.

    Declaration

    Swift

    public static func set(_ cases: [String], characterSet: MySQLCharacterSet? = nil, collate: MySQLCollation? = nil) -> MySQLDataType
  • MySQL supports a native JSON data type defined by RFC 7159 that enables efficient access to data in JSON (JavaScript Object Notation) documents.

    https://dev.mysql.com/doc/refman/8.0/en/json.html

    Declaration

    Swift

    public static var json: MySQLDataType { get }
  • See SQLSerializable.

    Declaration

    Swift

    public func serialize(_ binds: inout [Encodable]) -> String