作者:瀚高PG实验室 (Highgo PG Lab)- 海无涯
1、普通整数数据
create table te1 (id int);
insert into te1 select generate_series(1,1000);
highgo=# select * from te1 limit 5;
id
----
1
2
3
4
5
(5 rows)
2、常用规律数据模拟
create table te2 (id int,name text);
insert into te2 select generate_series(1,100),'highgo';
highgo=# select * from te2 limit 3;
id | name
----+--------
1 | highgo
2 | highgo
3 | highgo
(3 rows)
3、随机加密数据模拟
create table te3 (id int,MD5 vchar,TIME text);
insert into te3 select generate_series(1,5),md5(random()::highgo),clock_timestamp();
highgo=# select * from te3 limit 5;
id | md5 | time
----+----------------------------------+-------------------------------
1 | 311e7462a6242cbc0578f9d6d91d5d33 | 2018-03-31 10:06:24.2599+08
2 | 311e7462a6242cbc0578f9d6d91d5d33 | 2018-03-31 10:06:24.260049+08
3 | 311e7462a6242cbc0578f9d6d91d5d33 | 2018-03-31 10:06:24.26006+08
4 | 311e7462a6242cbc0578f9d6d91d5d33 | 2018-03-31 10:06:24.260065+08
5 | 311e7462a6242cbc0578f9d6d91d5d33 | 2018-03-31 10:06:24.260068+08
(5 rows)
random() double 0.0到1.0之间的随机数值
highgo=# insert into te3 select generate_series(106,110),random(),clock_timestamp();
INSERT 0 5
highgo=# select * from te3 where id >105 and id < 110;
id | md5 | time
-----+----------------------------------+-------------------------------
106 | 0.796067376621068 | 2018-03-31 10:50:50.45065+08
107 | 0.474363456480205 | 2018-03-31 10:50:50.450756+08
108 | 0.771753719076514 | 2018-03-31 10:50:50.450771+08
109 | 0.838413044810295 | 2018-03-31 10:50:50.45078+08
如需在表中添加列,请使用下列语法:
ALTER TABLE table_name ADD column_name datatype