Database, C #, Java generate unique GUID method

Source: Internet
Author: User
Tags table definition uuid

GUID (Global unique identifier) Globally unique identifier, which is a 16-byte binary value generated by the identity number on the network card (each network card has a unique identification number) and the unique number of the CPU clock.

The format of the GUID is "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", where each x is a hexadecimal number in the range of 0-9 or a-f. Example: 76895313-839e-4e89-bafc-b253bff3173f

No two computers in the world will generate duplicate GUID values. GUIDs are primarily used to assign identifiers that must be unique in a network or system that has multiple nodes, multiple computers, and more than one computer. On the Windows platform, GUIDs are widely used: Registry, class and interface identifiers, databases, even automatically generated machine names, directory names, and so on.

1.SQL Server Database
When you previously developed a SQL Server database that specifies a column type as uniqueidentifier in a table definition, the value of the column is the GUID type.

2. Using T-SQL to produce a GUID
Insert INTO table1 (id,name,...) VALUES (NewID (), ' Zhang San ',...)

3. Create a GUID in C #
GUID guid = Guid.NewGuid ();
Console.writeln (GUID. ToString ());

4. Create UUID in Java
Check the data on the Internet only to know in Java, become a UUID. The creation method is surprisingly simple System.out.println (Java.util.UUID.randomUUID ());

Excerpt from: http://qfqf16.blog.163.com/blog/static/128109527201272610564410/

Database, C #, Java generate unique GUID method

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.