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);
- 在pgsql中安装扩展
create extension "uuid-ossp" ;
- 查询
select uuid_generate_v4()