UUID (guid)

Source: Internet
Author: User

UUID and guid

UUID is a string generated after the 32-byte string is separated by four hyphens (-), with a total length of 36 bytes. For example: 550e8400-e29b-41d4-a716-446655440000

Http://gohands.blogbus.com/logs/147479174.html

GUID is Microsoft's implementation of the uuid standard. UUID is defined by the Open Software Foundation (OSF. UUID also has other implementations, more than guid. For example, we use it in Java.

Http://baike.baidu.com/view/1052579.htm

Comb (combine) is a database-specific design concept. It can be understood as an improved guid, which combines the guid and system time, to improve the indexing and retrieval performance.
Http://blog.csdn.net/happyflystone/article/details/1903854

There is no comb type in the database. It was designed by Jimmy Nilsson in his article "The cost of guids as primary keys.

The basic design of the comb data type is as follows: since the uniqueidentifier data causes low indexing efficiency and affects the system performance, can we use a combination, keep the first 10 bytes of uniqueidentifier, and use the last 6 bytes to indicate the time (datetime) generated by the guid. In this way, we combine the time information with uniqueidentifier, while retaining the uniqueness of uniqueidentifier, order is added to Improve Index efficiency.

Http://hi.baidu.com/%CA% AB %D5%B9/blog/item/407fd23f77d5eacf7c1e7122.html

 

AndroidCode:

Jdk1.5 started to support UUID, Android also supports UUID http://developer.android.com/reference/java/util/UUID.html

UUID generation becomes a simple task, because JDK implements UUID: Java. util. UUID, which can be called directly.
UUID = UUID. randomuuid ();
String S = UUID. randomuuid (). tostring (); // The primary key ID used to generate the database is very good.

 
ImportJava. util. UUID;
 
 
UUID uid = UUID. randomuuid ();

 

SQLite example

 
// Insert data
 
UUID locationid = UUID. randomuuid ();
 
Contentvalues initialvalues =NewContentvalues ();
 
Initialvalues. Put ("Rowid", Locationid. tostring ());
//... Other stuff ...//
 
DB. insert (database_table_locations,Null, Initialvalues );
 
 
 
// Search
 
Cursor c =
DB. Query (True, Database_table,NewString [] {
 
"Rowid","Stuff","Things"},"Rowid ='"+ Rowid +"'",
 
Null,Null,Null,Null);
 

The above code from: http://groups.google.com/group/android-developers/browse_thread/thread/4a6c40702107fa16

 

SQL statement

 
Create Table users
 
(
 
Userguid text primary key not null,
Firstname text,
 
Lastname text
 
)
 
 
 
Insert into users (userguid, firstname, lastname)
Values ('E7bf9773-8231-44af-8d53-e624f0433943','Bobby','Bobston')
 
 
 
Delete from users where userguid ='E7bf9773-8231-44af-8d53-e624f0433943'
 
 

The above statement Source: http://zh-cn.w3support.net/index.php? DB = also & id = 1055848

 

MySQL

In MySQL, a function generates guid: Select UUID ();

Generally, we use char (36) or binary (36) to store UUID.

 

Use UUID in PHP

Generate guid in PHP

Http://www.cnblogs.com/ovliverlin/archive/2008/08/27/932444.html

PHP function to generate V4 UUID

Http://stackoverflow.com/questions/2040240/php-function-to-generate-v4-uuid

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.