Re: ?How create a one serial decimal(500,0) column or simulate itwith bigint multicolumns serial?
От | Andreas Kretschmer |
---|---|
Тема | Re: ?How create a one serial decimal(500,0) column or simulate itwith bigint multicolumns serial? |
Дата | |
Msg-id | 95a1a7f8-1a8f-f759-7b72-735b4e47adc9@a-kretschmer.de обсуждение исходный текст |
Ответ на | ?How create a one serial decimal(500,0) column or simulate it withbigint multicolumns serial? (Dani <danielcheagle@gmail.com>) |
Список | pgsql-novice |
Am 07.01.2018 um 07:17 schrieb Dani: > Hi! All! > > I Need create a one decimal serial column or simulate it with multiple > columns of bigint. > > gaps don't are problem. > > pseudo-code: > > create table bank ( > id0 decimal( 500, 0) not null auto-increment, > etc text > ) > > or > > create table bank ( > id0 bigint not null, > id1 bigint not null, > id2 bigint not null, > idn bigint not null, > etc text > primary key(id0, id1, id2, idn), > auto_increment(id0, id1, id2, idn) > ) > > How a example of behavior (using a range of 1 .. 3) > > insert into bank(etc) Values "3*3*3 times 'Thanks'"; > > select * from bank; > > id0 id1 id2 idn text > 1 1 1 1 T > 1 1 1 2 T > 1 1 1 3 T > 1 1 2 1 T > 1 1 2 2 T > 1 1 2 3 T > 1 1 3 1 T > 1 1 3 2 T > 1 1 3 3 T > 1 2 1 1 T > etc. Not sure if i understand you, but maybe you are looking for somethink like this: test=*# select s, (s/9)%3 as "3^2", (s/3)%3 as "3^1", s%3 as "3^0" from generate_series(0,20) s; s | 3^2 | 3^1 | 3^0 ----+-----+-----+----- 0 | 0 | 0 | 0 1 | 0 | 0 | 1 2 | 0 | 0 | 2 3 | 0 | 1 | 0 4 | 0 | 1 | 1 5 | 0 | 1 | 2 6 | 0 | 2 | 0 7 | 0 | 2 | 1 8 | 0 | 2 | 2 9 | 1 | 0 | 0 10 | 1 | 0 | 1 11 | 1 | 0 | 2 12 | 1 | 1 | 0 13 | 1 | 1 | 1 14 | 1 | 1 | 2 15 | 1 | 2 | 0 16 | 1 | 2 | 1 17 | 1 | 2 | 2 18 | 2 | 0 | 0 19 | 2 | 0 | 1 20 | 2 | 0 | 2 (21 rows) test=*# -- 2ndQuadrant - The PostgreSQL Support Company. www.2ndQuadrant.com
В списке pgsql-novice по дате отправления: