pgsql中uuid使用

CREATE TABLE users (
  id            UUID            NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
  username      varchar(255)      NOT NULL,
  password      char(128)         NOT NULL,
  phone         varchar(255)      NOT NULL
);
-- 索引
CREATE INDEX index_users_on_username on users (username);
-- 唯一
CREATE UNIQUE INDEX index_users_on_phone on users (phone);
  1. 在pgsql中安装扩展
    create extension "uuid-ossp" ;
  2. 查询
    select uuid_generate_v4()
原文地址:https://www.cnblogs.com/liangyy/p/13065878.html