In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
The editor will share with you what data types are in the database. I hope you will get something after reading this article. Let's discuss it together.
What are the common data types of the database?
Integer data type: integer data type is one of the most commonly used data types.
1. INT (INTEGER)
The INT (or INTEGER) data type stores all positive and negative integers from the 31st power of-2 (- 2,147,483,648) to the 31st power of 2-1 (2,147,483647). Data of each INT type is stored in 4 bytes, where 1 bit represents the sign of the integer value, and the other 31 bits represent the length and size of the integer value.
2 、 SMALLINT
The SMALLINT data type stores all positive and negative integers from-2 to the 15th power of 2 (- 32768) to the 15th power of 2-1 (32767). Each SMALLINT type data takes up 2 bytes of storage space, where 1 bit represents the sign of the integer value, and the other 15 bits represent the length and size of the integer value.
Floating-point data types: floating-point data types are used to store decimal decimals. Floating-point data is stored in SQL Server by rounding up (Round up or rounding only).
1. REAL data type
The REAL data type can be accurate to the seventh decimal place, ranging from-3.40E-38 to 3.40E + 38. Each REAL type of data takes up 4 bytes of storage space.
2 、 FLOAT
The FLOAT data type can be accurate to the 15th decimal place, ranging from-1.79E-308 to 1.79E + 308. Each FLOAT type of data takes up 8 bytes of storage space. The FLOAT data type can be written as FLOAT [n]. N specifies the precision of the FLOAT data. N is an integer value between 1 and 15.
When n takes 1 to 7, it actually defines a data of type REAL, and the system stores it in 4 bytes; when n takes 8 to 15:00, the system thinks it is of type FLOAT and stores it in 8 bytes.
Third, binary data type
1 、 BINARY
The BINARY data type is used to store binary data. It is defined as BINARY (n), where n represents the length of the data, with values ranging from 1 to 8000. You must specify the size of the BINARY type data when using it, which should be at least 1 byte. BINARY type data takes up 4 bytes of storage space.
When entering data, you must precede the data with the character "0X" as a binary identity. For example, to enter "abc", you should enter "0xabc". If the input data is too long, the excess will be truncated. If the number of data bits entered is odd, a 0 will be added after the starting symbol "0X". For example, the above "0xabc" will be automatically changed to "0x0abc" by the system.
2 、 VARBINARY
The VARBINARY data type is defined as VARBINARY (n). It is similar to the BINARY type, with a value of 1 to 8000, and if the input data is too long, the excess will be truncated.
The difference is that the VARBINARY data type has a variable length, because the storage length of the VARBINARY data type is the actual numeric length + 4 bytes. When the BINARY data type allows NULL values, it is considered the VARBINARY data type.
IV. Logical data types
1. BIT: the BIT data type takes up 1 byte of storage, with a value of 0 or 1. If you enter a value other than 0 or 1, it is considered 1. The BIT type cannot be defined as a NULL value (the so-called NULL value is a null or meaningless value).
Character data type: character data type is the most frequently used data type. It can be used to store all kinds of letters, numeric symbols and special symbols. In general, character type data must be preceded by single or double quotation marks.
1 、 CHAR
The CHAR data type is defined as CHAR [(n)]. Each character and symbol stored in the CHAR type takes up one byte of storage space. N represents the storage space occupied by all characters. Values of n range from 1 to 8000, which can hold 8000 ANSI characters.
If you do not specify an n value, the system default value is 1. If the number of characters in the input data is less than n, the system automatically adds a space after it to fill the set space. If the input data is too long, the excess will be truncated.
Extended data:
SQL includes all operations on the database and is mainly composed of four parts:
1. Data definition: this part, also known as "SQL DDL", defines the logical structure of the database, including defining the database, basic tables, views and indexes.
2. Data manipulation: this part, also known as "SQL DML", includes two types of operations: data query and data update, in which data update includes insert, delete and update operations.
3. Data control: the control of user access to data includes authorization of basic tables and views, description of integrity rules, transaction control statements, etc.
4. The rules for the use of embedded SQL language: the rules for the use of SQL statements in host language programs.
After reading this article, I believe you have a certain understanding of "what data types are in the database". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for your reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.