Re: Moving from MySQL to PGSQL....some questions (multilevel

Поиск
Список
Период
Сортировка
Искать
От
Harald Fuchs
Тема
Re: Moving from MySQL to PGSQL....some questions (multilevel
Дата
Msg-id
pu65dluasp.fsf@srv.protecting.net
Список
Дерево обсуждения
Re: Moving from MySQL to PGSQL....some questions (multilevel Harald Fuchs <hf118@protecting.net>
Re: Moving from MySQL to PGSQL....some questions (multilevel Paulovič Michal <michal@paulovic.sk>
Re: Moving from MySQL to PGSQL....some questions (multilevel Bruno Wolff III <bruno@wolff.to>
Re: Moving from MySQL to PGSQL....some questions (multilevel Paulovič Michal <michal@paulovic.sk>
In article ,
"scott.marlowe"  writes:

> On Tue, 2 Mar 2004, [UTF-8] Paulovič Michal wrote:
>> how you solve the problem with multilevel autoicrement?
>> 
>> In MySQL you create table with col1, col2. Col 2 is AUTOICREMENT and you 
>> have to create UNIQUE INDEX (Col1, Col2). If you insert to this table 
>> for col1 volume 1, col2 automaticaly increase by one.
>> 
>> Example:
>> Insert into table values (1);
>> Insert into table values (1);
>> Insert into table values (2);
>> Insert into table values (1);
>> Insert into table values (2);

> I did this in MySQL and got this:

> create table test (id1 int, id2 int auto_increment, primary key(id2));
> Query OK, 0 rows affected (0.00 sec)

mysql> alter table test add unique index (id1, id2);
> Query OK, 0 rows affected (0.09 sec)
> Records: 0  Duplicates: 0  Warnings: 0

You can't have a multi-level autoincrement if you make the second
level unique.  Use the following instead:

  create table test (id1 int, id2 int auto_increment, primary key(id1,id2));

Note that this trick works only for the MyISAM and BDB table types,
not for InnoDB.
В списке pgsql-general по дате отправления
От: Palle Girgensohn
Дата:
От: Paulovič Michal
Дата:
FAQ