Postgresql 8.3获取uuid方法需先导入uuid-ossp.sql文件
C:\Postgresql\8.3\bin>psql -ddbname -Uuname -f C:\Postgresql\8.3\share\contrib\uuid-ossp.sql
select regexp_replace(''||uuid_generate_v4(),'-','','g');
select regexp_replace(''||uuid_generate_v4(),'g') as pk_new,pk_id from table;
查询两千条数据4000毫秒,效率低;
当前时间+行号
create sequence seq_rownum;
select setval('seq_rownum',1);
select to_char(now(),'yyyymmddhh24miss')||lpad(''||(nextval('seq_rownum')-1),18,'0')as pk_new,pk_id from table;
查询两千条数据80毫秒
select sys_guid() from dual;
select sys_guid() as pk_new,pk_id from table;
查询两千条数据30毫秒
原文链接:https://www.f2er.com/postgresql/195744.html