Home > Computers and Internet > [PostgreSQL] 연번 필드 생성

[PostgreSQL] 연번 필드 생성

0000 – 0100 문자열 생성

with recursive foo
AS
(
SELECT 0 seq
UNION ALL
SELECT seq + 1 FROM foo
WHERE seq + 1 <= 100
)
select lpad(cast (seq as varchar(8)), 4, ‘0’) from foo;

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: