如何在ORDER BY中订购uuid列?

时间:2017-12-21 03:22:28

标签: postgresql

library(data.table) rbindlist(split.default(as.data.table(df), c(0, sequence(ncol(df)-1) %/% 3)), use.names = FALSE) ## V1 V2 V3 ## 1: 1 2 3 ## 2: 4 5 6 ## 3: 7 8 9 ## 4: 10 11 12 ## 5: 13 14 15 ## 6: 16 NA NA ## 7: 19 20 21 ## 8: 22 23 24 一起使用时,uuid列的排序方式如何?它是基于它的字符串表示?我似乎无法找到有关此问题的任何文件。

1 个答案:

答案 0 :(得分:5)

PostgreSQL中的这个函数compares UUIDs

/* internal uuid compare function */
static int
uuid_internal_cmp(const pg_uuid_t *arg1, const pg_uuid_t *arg2)
{
    return memcmp(arg1->data, arg2->data, UUID_LEN);
}

因此,使用二进制值在字节上逐字节地比较UUID。