0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

postgresで連番をinsertする

Posted at

明細テーブルに「行番号」フィールドがあることってありますよね。
そういうのって、探しても見つからなかったので、頑張って書いたので、一応、記録残しておきます。

insert into meisai (line_no, summary_id, name ,units)
    select row_number() over (), 1, * from (
        select 'item1', 1 
        union all select 'item2', 1 
        union all select 'item3', 1 
        union all select 'item4', 1 
        union all select 'item5', 1 
    ) as line

こんな感じで連番ふれます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?