E
E
eliasum2021-12-01 12:50:50
PostgreSQL
eliasum, 2021-12-01 12:50:50

How to insert 300 rows into a table?

How to insert 300 rows into a table:

CREATE TABLE table_Number(
  key integer NOT NULL,
  tstamp timestamptz NOT NULL);

where key is not a primary key and is filled with numbers 1,2,3...300, tstamp - generate_series(NOW() - INTERVAL '90 days', NOW(),'1 min')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2021-12-01
@eliasum

Still, it was easier to make key serial.

insert into table_Number (key, tstamp)
select * from (
  select row_number() over () n, t
  	  from generate_series(NOW() - INTERVAL '90 days', NOW(),'1 min') t
  ) sq
 where n <= 300

https://www.db-fiddle.com/f/bzE1G4cQ8S6sCHHPFH64gx/0

N
Nikolay Savelyev, 2021-12-01
@AgentSmith

insert into

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question