Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9EB439FA5B4 for ; Sun, 15 Oct 2006 12:23:13 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 46326-06 for ; Sun, 15 Oct 2006 12:23:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id AAC2E9FB1DE for ; Sun, 15 Oct 2006 12:23:06 -0300 (ADT) Received: from tedy ([70.82.131.58]) by VL-MH-MR002.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0J76000AMO2HB180@VL-MH-MR002.ip.videotron.ca> for pgsql-sql@postgresql.org; Sun, 15 Oct 2006 11:23:06 -0400 (EDT) Date: Sun, 15 Oct 2006 11:23:01 -0400 From: Daniel CAUNE Subject: Re: migrating numeric to serial from MSSQL to postgres In-reply-to: <45323DA5.1080601@ashtonwoodshomes.com> To: 'Terry Fielder' , 'Kenneth Gonsalves' Cc: pgsql-sql@postgresql.org Message-id: <001001c6f06d$cdd508b0$0b00a8c0@tedy> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Mailer: Microsoft Office Outlook 11 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Thread-index: AcbwYZ4BP8Fct1j9T+eKNxKwxlnvJAACTxYg X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200610/143 X-Sequence-Number: 26532 > I believe: > IDENTITY(1, 1) just means "Primary Key" in M$SQL > IDENTITY is not obligatory a primary key. It's an auto-incremented column. It might correspond to a PostgreSQL sequence. [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts _ia-iz_3iex.asp] > numeric 18,0 means a numeric field of zero decimal points. Hence we are > looking at a 18 byte integer. bigint is not big enough, so probably > should use the same in numeric 18,0 in postgres > numeric[ (precision[ , scale] )], where precision refers to the maximum total number of decimal digits that can be stored. The default precision is 18, and for such a value the storage is of 9 bytes. [http://msdn2.microsoft.com/en-us/library/ms187746.aspx] Because it seems that a default value has been used here, I'd say that Kenneth doesn't have any particular requirement, haven't you Kenneth?... :-) An int or a bigint would be perhaps sufficient. My two cents. I don't know whether Kenneth requires migrating database structure only or whether he needs to migrate data too. When migrating data, Kenneth might want to define a sequence which start value begins at the next value of its IDENTITY column (cf. IDENT_SEED(my_table)). [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts _ia-iz_9yxw.asp] Kenneth might want to transfer his data first and to define the sequence after (for transfer performance reason?): CREATE TABLE my_table ( Id INTEGER NOT NULL, ... ); [DTS process here] CREATE SEQUENCE my_sequence INCREMENT BY 1 MINVALUE 1 NO MAXVALUE START WITH CACHE 1 NO CYCLE; ALTER TABLE m_table ALTER COLUMN Id SET DEFAULT NEXTVAL('my_sequence'); Does that make sense? -- Daniel