使用 SQL 查询生成 100 行随机数据
Generate 100 rows with random data using SQL query
我使用这个 SQL 查询插入 1 行数据:
INSERT INTO public.tasks (id, business_name, meta_title, status, title, type) VALUES (
'10'::bigint, 'business name 1'::character varying, 'meta title 1'::character varying, 'active'::character varying, 'title 1'::character varying, 'merchant'::character varying)
returning id;
是否可以使用 1 SQL 查询将 100 行随机数据插入 Postgre table?
INSERT into tasks SELECT generate_series(1,100) AS id,
md5(random()::text) AS business_name,
md5(random()::text) AS meta_title,
md5(random()::text) AS status,
md5(random()::text) AS title,
md5(random()::text) AS type
我使用这个 SQL 查询插入 1 行数据:
INSERT INTO public.tasks (id, business_name, meta_title, status, title, type) VALUES (
'10'::bigint, 'business name 1'::character varying, 'meta title 1'::character varying, 'active'::character varying, 'title 1'::character varying, 'merchant'::character varying)
returning id;
是否可以使用 1 SQL 查询将 100 行随机数据插入 Postgre table?
INSERT into tasks SELECT generate_series(1,100) AS id,
md5(random()::text) AS business_name,
md5(random()::text) AS meta_title,
md5(random()::text) AS status,
md5(random()::text) AS title,
md5(random()::text) AS type