Обсуждение: Porting from MySQL to postgreSQL. Question RE: Sequence Dependencies

Поиск
Список
Период
Сортировка

Porting from MySQL to postgreSQL. Question RE: Sequence Dependencies

От
Robert Starr
Дата:
Hi all,  this is my first post.  I have a quick question, and if I have 
it all wrong I apologise in advance, I'm still trying to get used to a 
'real' SQL after moving away from MySQL.

I am using pgAdminIII and have created a table called 'clients' and 
filled it with data.  I then tried to edit the table so there would be a 
primary key, and auto increment etc.  
What I've noticed, is if I create a NEW column, and make it of type 
'serial' then it automatically creates a sequence, but if I want to go 
and edit a pre-existing column and change it from type 'integer' to type 
'serial' I cannot.

That is fine, I added nextval('clients_id_seq'::regclass) to the Default 
Value of my ID column, and I even added a sequence called 
'clients_id_seq' but the thing is, there is no dependency between the 
column and the sequence.

How can I go about linking the two?  I'm a bit stuck :)

Any help would be really appreciated.

Rob


Re: Porting from MySQL to postgreSQL. Question RE: Sequence Dependencies

От
Charlie Clark
Дата:
Am 13.09.2007 um 05:24 schrieb Robert Starr:

> Hi all,  this is my first post.  I have a quick question, and if I
> have it all wrong I apologise in advance, I'm still trying to get
> used to a 'real' SQL after moving away from MySQL.

Welcome aboard!

This list is actually for pgAdmin which is just the GUI admin tool
for the PostgreSQL RDBMS. You might want to sign-up to one of the
postgresql lists such as the general list for questions.
From your posts it looks like you understand the principles of
relational databases which PostgreSQL actually implements rather than
just paying lip service. And if you think relationally you'll find
PostgreSQL a lot more fun to work with. For migrating from MySQL it's
probably worth noting that there is an option for exporting MySQL in
nearly PostgreSQL compatible syntax. I don't know if there is a
migration guide but there probably should be.

Good luck with your migration!

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226