1、INT? (integer)
The storage range of INT (or INTEGER) data type is from -2 to the power of 3 1 (-2, 147,483,648) to the power of 2 to 3 1-/(2,147). Each INT type data is stored in 4 bytes, where 1 bit represents the sign of the integer value, and the other 3 1 bits represent the length and size of the integer value. ?
2、SMALLINT
The SMALLINT data type stores all positive and negative integers from -2 to15 (-32,768) to 2 to15-1(32,767). Each SMALLINT type of data occupies 2 bytes of storage space, where 1 bit represents the sign of the integer value, and 15 bit represents the length and size of the integer value.
Second,? Floating-point data type: Floating-point data type is used to store decimals. Data of floating-point values are stored in SQL Server by rounding.
1, true? data type
Real data types can be accurate to the seventh decimal place, ranging from -3.40E -38 to 3.40E +38. Each real data occupies 4 bytes of storage space.
2. Floating
The data type of FLOAT can be accurate to15th place after the decimal point, ranging from-1.79E -308 to 1.79E +308. Each floating-point data occupies 8 bytes of storage space. The FLOAT data type can be written as FLOAT[ n]. N specifies the precision of floating-point data. N is an integer value between 1 and 15.
When n takes 1 to 7, it actually defines a real number type of data, and the system stores it in 4 bytes; When n takes 8 to 15, the system thinks it is a floating-point number type and stores it in 8 bytes.
Third,? Binary data type
1, binary?
Binary data types are used to store binary data. Its definition is BINARY( n), where n represents the length of data, and the value is 1 to 8000. When using binary data, you must specify its size, which should be at least 1 byte. Binary data occupies n+4 bytes of storage space.
When inputting data, the character "0X" must be added before the data as a binary identification. For example, if you enter "abc", you should enter "0xabc". If the input data is too long, the excess will be truncated. If the number of data bits input is odd, add a 0 after the starting symbol "0X", for example, the above "0xabc" will be automatically changed to "0bc" by the system.
2、VARBINARY
The VARBINARY data type is defined as VARBINARY(n). Similar to binary types, the value of n is 1 to 8000. If the input data is too long, the excess will be truncated.
The difference is that the VARBINARY data type has the characteristic of variable length, because the storage length of the VARBINARY data type is the actual numerical length +4 bytes. When a binary data type allows null values, it will be treated as a VARBINARY data type. ?
Fourth,? Logical data type
1, bit:? The BIT data type occupies 1 byte of storage space, and its value is 0 or 1. If you enter a value other than 0 or 1, it will be regarded as 1. Bit types cannot be defined as null values (null values are null values or meaningless values).
Verb (short for verb)? Character data type: Character data type is the most commonly used data type. It can be used to store all kinds of letters, numerical symbols and special symbols. Usually, you must add single or double quotation marks before and after character type data. ?
1、CHAR?
The CHAR data type is defined as CHAR[ (n)]. Each character and symbol stored in CHAR type occupies one byte of storage space. N represents the storage space occupied by all characters, and the value of n is 1 to 8000, which can accommodate 8000 ANSI characters.
If no value of n is specified, the system default value is 1. If the number of characters in the input data is less than n, the system will automatically add spaces after it to fill the set spaces. If the input data is too long, the excess will be truncated. ?
Extended data:
SQL includes all operations on the database, which is mainly composed of four parts:
1. Data definition: This part is also called "SQL DDL" and defines the logical structure of the database, including defining the database, basic tables, views and indexes.
2. Data operation: this part is also called "SQL DML", which includes two operations: data query and data update, among which data update includes three operations: insert, delete and update.
3. Data control: Users can access data by authorizing basic tables and views, describing integrity rules and transaction control statements.
4. Rules for the use of embedded SQL language: rules for using SQL statements in programs in the host language.
Baidu encyclopedia-SQL database