On the differences and usage of string types in database

Source: Internet
Author: User
Data type of database: integer: Int,smallint,bigint,decimal real type: float,real. String type:Char/nchar,Varchar/nvarchar. 1. There is no difference between VAR: a variable-length string type with Var, and a fixed length string without var. Fixed-Length field, if the stored data does not reach the maximum length, the system will fill the string behind the input space. When the recorded data has a fixed length, the selected length (Char/nchar) is used. When it is not possible to determine how long the recorded data is, choose a variable length (varchar/nchar) fixed length: It is easy to waste storage space, but the query efficiency is high.    Variable length: Saves storage space, but query efficiency is low. 2. N Difference: Data type data with n is Unicode encoded, without n is non-Unicode encoding. Unicode uses 2 bytes to store 1 characters. Use with n : When this field needs to store more Chinese characters, be sure to use N. These 4 data types must be set to its maximum length in use: nvarchar (12), "can store 12 Chinese characters and or 12 English letters" char (12) "can store 6 Chinese characters and 12 English letters". Maximum Length: Char/varchar (8000), Nchar/nvarchar (4000) 3 Text/ntext is used to store oversize text. Image type: image, in binary form, the picture is stored in the database file (infrequently used). Generally, the picture is stored as a file string on the server, the database only stores the path of the picture. Only when the security requirements of the picture is particularly high, the image will be stored directly in the database.

On the differences and usage of string types in database

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.