Basic Data Types of common databases

Source: Internet
Author: User
Data Type description storage Text is used for a combination of up to 255 characters in Text or Text and numbers. MemoMemo is used for a larger number of texts. It can store up to 65,536 characters. Note: memo fields cannot be sorted. However, they are searchable. Bytes can contain numbers ranging from 0 to 255. 1-byte Integer allowed between-32,768

Data Type description storage Text is used for a combination of up to 255 characters in Text or Text and numbers. Memo is used for a larger number of texts. It can store up to 65,536 characters. Note: memo fields cannot be sorted. However, they are searchable. Bytes can contain numbers ranging from 0 to 255. 1-byte Integer allowed between-32,768

Data Type description Storage
Text is a combination of up to 255 characters in Text or Text and numbers.
Memo
Memo is used for a larger number of texts. It can store up to 65,536 characters.
Note: memo fields cannot be sorted. However, they are searchable.

Bytes can contain numbers ranging from 0 to 255. 1 byte
Integer allows numbers between-32,768 and 32,767. 2 bytes
Long allows 4 bytes of all numbers between-2,147,483,648 and 2,147,483,647
Single precision Floating Point. Process most decimals. 4 bytes
Double-precision floating point. Process most decimals. 8 bytes
Currency
Used in currency. Supports 15-digit RMB, plus 4 decimal places.
Tip: You can select the country currency to use.
8 bytes
The AutoNumber Field automatically assigns a number for each record, usually starting from 1. 4 bytes
Date/Time is used for 8 bytes of Date and Time
Yes/No
Logical field, which can be displayed as Yes/No, True/False, or On/Off.
In the code, use constants True and False (equivalent to 1 and 0)
Note: Null values are not allowed in the Yes/No field.
1 bit
Ole Object can store images, audios, videos, or other BLOBs (Binary Large OBjects) up to 1 GB
Hyperlink contains links to other files, including webpages.
Lookup Wizard allows you to create a list of options that can be selected from the following list. 4 bytes


MySQL Data Type
In MySQL, there are three main types: Text, numbers, and date/time.
Text Type:
Data Type description
CHAR (size) Stores fixed-length strings (including letters, numbers, and special characters ). Specify the length of the string in parentheses. It can contain a maximum of 255 characters.
VARCHAR (size)
Saves variable-length strings (including letters, numbers, and special characters ). Specify the maximum length of the string in parentheses. It can contain a maximum of 255 characters.
Note: If the value length is greater than 255, it is converted to the TEXT type.
TINYTEXT stores strings with a maximum length of 255 characters.
TEXT is a string of up to 65,535 characters.
BLOB is used for BLOBs (Binary Large OBjects ). Stores up to 65,535 bytes of data.
MEDIUMTEXT stores strings with a maximum length of 16,777,215 characters.
MEDIUMBLOB is used for BLOBs (Binary Large OBjects ). Stores up to 16,777,215 bytes of data.
LONGTEXT stores strings with a maximum length of 4,294,967,295 characters.
LONGBLOB is used for BLOBs (Binary Large OBjects ). Stores up to 4,294,967,295 bytes of data.
ENUM (x, y, z, etc .)
You can enter a list of possible values. You can list a maximum of 65535 values in the ENUM list. If no inserted value exists in the list, a null value is inserted.
Note: These values are stored in the order you entered.
Possible values can be entered in this format: ENUM ('x', 'y', 'z ')
Similar to ENUM, SET can contain up to 64 list items, but SET can store more than one value.
Number Type:
Data Type description
TINYINT (size)-128 to 127. 0 to 255 unsigned *. Specify the maximum number of digits in parentheses.
SMALLINT (size)-32768 to 32767. 0 to 65535 unsigned *. Specify the maximum number of digits in parentheses.
MEDIUMINT (size)-8388608 to 8388607 normal. 0 to 16777215 unsigned *. Specify the maximum number of digits in parentheses.
INT (size)-2147483648 to 2147483647. 0 to 4294967295 unsigned *. Specify the maximum number of digits in parentheses.
BIGINT (size)-9223372036854775808 to 9223372036854775807. 0 to 18446744073709551615 unsigned *. Specify the maximum number of digits in parentheses.
FLOAT (size, d) is a small number with a floating decimal point. Specify the maximum number of digits in parentheses. Specify the maximum number of digits to the right of the decimal point in parameter d.
DOUBLE (size, d) is a large number with a floating decimal point. Specify the maximum number of digits in parentheses. Specify the maximum number of digits to the right of the decimal point in parameter d.
DECIMAL (size, d) is the DOUBLE type stored as a string. A fixed DECIMAL point is allowed.
* These integer types have additional options UNSIGNED. Generally, integers can be negative or positive. If the UNSIGNED attribute is added, the range starts from 0, instead of a negative number.
Date type:
Data Type description
DATE ()
Date. Form: YYYY-MM-DD
Note: The supported range is from '2017-01-01 'to '2017-12-31'
DATETIME ()
* Combination of date and time. YYYY-MM-DD HH: MM: SS
Note: The supported range is from '2017-01-01 00:00:00 'to '2017-12-31 23:59:59'
TIMESTAMP ()
* Timestamp. The TIMESTAMP value is stored in the Unix epoch ('2017-01-01 00:00:00 'UTC) to date. YYYY-MM-DD HH: MM: SS
Note: The supported range is from '2017-01-01 00:00:01 'UTC to '2017-01-09 03:14:07' UTC
TIME. Format: HH: MM: SS Note: The supported range is from '-838: 59: 59' to '2017: 59: 59'
YEAR ()
2-digit or 4-digit year.
Note: values allowed in 4-digit format: 1901 to 2155. Value Range: 70 to 69, which indicates that the value ranges from 1970 to 2069.
* Even if DATETIME and TIMESTAMP return the same format, they work in different ways. In Insert or Update queries, TIMESTAMP automatically sets itself to the current date and time. TIMESTAMP also accepts different formats, such as YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD, or YYMMDD.


SQL Server Data Type
Character string:
Data Type description Storage
A char (n) string of a fixed length. It can contain a maximum of 8,000 characters. N
A variable-length string of varchar (n. It can contain a maximum of 8,000 characters.
A variable-length string of varchar (max. It can contain a maximum of 1,073,741,824 characters.
A variable-length text string. Up to 2 GB character data.
Unicode string:
Data Type description Storage
Unicode data with a fixed length of nchar (n. It can contain a maximum of 4,000 characters.
Unicode data with a variable length of nvarchar (n. It can contain a maximum of 4,000 characters.
Unicode data with a variable length of nvarchar (max. It can contain a maximum of 536,870,912 characters.
Unicode data with variable ntext length. Up to 2 GB character data.
Binary type:
Data Type description Storage
Bit allows 0, 1, or NULL
Binary (n) binary data of a fixed length. Up to 8,000 bytes.
Varbinary (n) binary data with variable length. Up to 8,000 bytes.
Varbinary (max) binary data with variable length. The maximum size is 2 GB.
Binary data with variable image length. 2 GB at most.
Number Type:
Data Type description Storage
Tinyint allows all numbers from 0 to 255. 1 byte
Smallint allows all numbers from-32,768 to 32,767. 2 bytes
Int allows all numbers from-2,147,483,648 to 2,147,483,647. 4 bytes
Bigint allows all numbers between-9,223,372,036,854,775,808 and 9,223,372,036,854,775,807. 8 bytes
Decimal (p, s)
Fixed Number of precision and proportion. A number ranging from-10 ^ 38 + 1 to 10 ^ 38-1 is allowed.
The p parameter indicates the maximum number of digits that can be stored (left and right of the decimal point ). P must be a value between 1 and 38. The default value is 18.
The s parameter indicates the maximum number of digits stored on the right of the decimal point. S must be the value between 0 and p. The default value is 0.
5-17 bytes
Numeric (p, s)
Fixed Number of precision and proportion. A number ranging from-10 ^ 38 + 1 to 10 ^ 38-1 is allowed.
The p parameter indicates the maximum number of digits that can be stored (left and right of the decimal point ). P must be a value between 1 and 38. The default value is 18.
The s parameter indicates the maximum number of digits stored on the right of the decimal point. S must be the value between 0 and p. The default value is 0.
5-17 bytes
The monetary data of smallmoney between-214,748.3648 and 214,748.3647. 4 bytes
Monetary data between-922,337,203,685,477.5808 and 922,337,203,685,477.5807. 8 bytes
Float (n) is a floating precision digital data from-1.79E + 308 to 1.79E + 308. Parameter n indicates whether the field is 4-byte or 8-byte. Float (24) saves 4 bytes, while float (53) saves 8 bytes. The default value of n is 53. 4 or 8 bytes
Real floating precision digital data from-3.40E + 38 to 3.40E + 38. 4 bytes
Date type:
Data Type description Storage
Datetime is accurate to January 1-9, 1753 milliseconds from January 1, December 31, 999 to January 1, 3.33. 8 bytes
From January 1, January 1-9, 1753, December 31, 999, datetime2 precision is 100 nanoseconds. 6-8 bytes
The accuracy of smalldatetime is 1 minute from January 1, January 1-20, 1900 to January 1, June 6. 4 bytes
Date only stores the date. From January 1, January 1-9, 0001 to January 1, December 31, 999. 3 bytes
Time only stores time. The precision is 100 nanoseconds. 3-5 bytes
Datetimeoffset is the same as datetime2, plus the time zone offset. 8-10 bytes
Timestamp stores a unique number. This number is updated whenever a row is created or modified. The timestamp is based on the internal clock and does not correspond to the actual time. Each table can have only one timestamp variable.


Other data types:
Data Type description
SQL _variant stores up to 8,000 bytes of data of different data types, except text, ntext, and timestamp.
Uniqueidentifier stores the GLobal IDEntifier (GUID ).
Xml stores XML formatted data. 2 GB at most.
Cursor stores references to pointers used for database operations.
Table stores the result set for later processing.


MSSQL2008 Data Type
Data Type
Type
Description
Bit
Integer
The bit data type is an integer, and its value can only be 0, 1, or null. This data type is used to store data with only two possible values, such as Yes, No, True, or Fa lse, On, or Off.
Int
Integer
Int data type can store integers from-231 (-2147483648) to 231 (2147483 647. This type can be used for almost all numeric data stored in the database. This data type occupies 4 bytes in the database.
Smallint
Integer
The smallint data type can store integers from-215 (-32768) to 215 (32767. This type of data is useful for storing numeric data that is often limited to a specific range. This data type occupies 2 bytes of space in the database.
Tinyint
Integer
The tinyint data type can store integers ranging from 0 to 255. It is useful when you only plan to store a limited number of values. This data type occupies 1 byte in the database
Numeric
Exact numeric type
Numeric has the same data type as decimal.
Decimal
Exact numeric type
The decimal data type can be used to store numeric data with fixed precision and range from-1038-1 to 1038-1. When using this data type, you must specify the range and precision. The range is the total number of digits that can be stored around the decimal point. Precision is the number of digits stored on the right of the decimal point.
Money
Currency type
The money data type is used to indicate money and currency values. This data type can store data from-922 billion to 922 billion, accurate to one thousandth of the currency unit
Smallmoney
Currency type
The smallmoney data type is used to indicate money and currency values. This data type can store data from-214748.3648 to 214748.3647, accurate to one thousandth of the currency unit
Float
Approximate numeric type
Float data is an approximate value type for floating point numbers. Floating Point Numbers are similar because not all numbers in the range can be accurately expressed. Floating Point number can be any number from-1.79E + 308 to 1.79E + 308
Real
Approximate numeric type
The real data type is similar to a floating point number and is an approximate value type. It indicates the floating point number between-3.40E + 38 and 3.40E + 38.
Datetime
Datetime type
The datetime data type is used to represent the date and time. This data type stores all the date and time data from January 1, 1/300 to 3.33 seconds or milliseconds.
Smalldatetime
Datetime type
The smalldatetime data type is used to indicate the date and time from January 1, January 1-20, 1900 to January 1, June 6, accurate to one minute.
Cursor
Special Data Type
The cursor data type is a special data type that contains a reference to the cursor. This type of data is used in the stored procedure and cannot be used when creating a table.
Timestamp
Special Data Type
The timestamp data type is a special data type used to create a unique digital within the database range. A table can have only one timestamp column. The value of the timestamp column changes each time a row is inserted or modified. Although its name contains "time", the timestamp column is not a date that people can recognize. In a database, the timestamp value is unique.
Uniqueidentifier
Special Data Type
The Uniqueidentifier data type is used to store a globally unique identifier (GUID. GUID is indeed globally unique. This number has almost no chance of being rebuilt in another system. You can use the NEWID function or convert a string to a unique identifier to initialize a column with a unique identifier.
Char
Character Type
The char data type is used to store non-uniform encoded data with a fixed length. When defining a column of this type, you must specify the column length. This data type is useful when you always know the length of the data to be stored. For example, when you store data in zip code and 4 character format, you know that it always takes 10 characters. The column width of this data type is up to 8000 characters
Varchar
Character Type
The varchar data type, same as the char type, is used to store non-uniform encoding character data. Unlike char, the data type is variable. When defining a column as the data type, you must specify the maximum length of the column. The biggest difference between it and char data types is that the storage length is not the column length, but the data length.
Text
Character Type
The text data type is used to store a large amount of non-uniform encoding character data. This data type can contain a maximum of 2 billion to characters
Nchar
Unified encoding type
The nchar data type is used to store fixed-length, unified encoding data. Unified encoding uses a dual-byte structure to store each character, rather than a single byte (in common text ). It allows a large number of extended characters. This data type can store 4000 characters, doubling the byte space used
Nvarchar
Unified encoding type
The nvarchar data type is used as a variable-length uniform encoding type data. This data type can store 4000 characters, and the byte space is doubled.
Ntext
Unified encoding type
The ntext data type is used to store a large amount of uniform encoding data. This data type can store 230-1 or nearly 1 billion characters, and the byte space is doubled.
Binary
Binary data type
The binary data type is used to store binary data that can be up to 8000 bytes in length. When the content of the input table is close to the same length, you should use this data type.
Varbinary
Binary data type
The varbinary data type is used to store up to 8000 bytes of long binary data. This type of data should be used when the content size of the input table is variable.
Image
Binary data type
The image data type is used to store variable-length binary data up to 2 billion-1-1 or approximately bytes.

Basic oracle data types:

Meaning of Data Type
Char fixed-length bytes data with a maximum length of 2 kb
Nchar stores the fixed-length bytes data of the Unicode character set. The maximum length is 2 kb.
Varchar2 variable-length bytes data up to 4000 characters
Nvarchar2 stores variable-length bytes data of the Unicode character set. The maximum length is 4 kb.
Number stores integer or floating point data
Date stores Date data
Long stores variable-length data with a maximum length of 2 GB
Raw stores variable-length character data of unstructured data, up to 2 kb
Long Raw stores variable-length character data of unstructured data, up to 2 GB
Rowid stores the binary data of the physical address of the column in the table, occupying 10 fixed bytes
Blog Binary large object with a maximum length of 4 GB
Clob character large object with a maximum length of 4 GB
Nclob stores up to 4 GB Unicode character data
Bfile stores unstructured binary data in operating system files other than databases
Urowid stores binary data that represents any type of column address
Float storage floating point number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.