SQL uniqueidentifier data types

Source: Internet
Author: User
Tags md5 hash

In SQL, ROWGUIDCOL indicates that the new column is the globally unique identifier column of the row. Only one uniqueidentifier column can be assigned to each table as the ROWGUIDCO column. The ROWGUIDCOL attribute can only be assigned to the uniqueidentifier column

Uniqueidentifier:

1. Use the NewID () function to implement

2. Directly convert the constant of the string to xxxxxxxx-xxxx-xxxxxxxxxxxx

Example: 6F9619FF-8B86-D011-B42D-00C04FC964FF

3. Directly assign 32-bit sixteen-bit data

For example, 0xffffffffffffffffffffff00000000


Others

In SQL Server 2005, there is a data type uniqueidentifier, which is used to support GUID (Global Unique Identifier ). The value of this type is a 32-length string, for example, "00000002-3378-a87f-92pj-2t68i97o34ms ". GUID can ensure the global uniqueness of the ID and facilitate database integration, so as to avoid unnecessary conflicts due to the same ID during data Copy and conversion. In C #, there is a Guid class, which facilitates us to generate and operate GUIDs. For example, you can obtain a new Guid by using GUID. NewGuid. ToString. In fact, GUID can be considered as the MD5 Hash of the timestamp. In Lotus, each Document has a globally unique identifier called UNID (unique identifier ). This UNID has the same mechanism as the GUID. In my recent project, I have completed the transformation from a Lotus document database to an SQL Server relational database. It involves many operations on GUID and UNID. In SQL Server 2005, the uniquidentifier type value can always be converted to a varchar type with a fixed length (32) using casting.

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.