Re: datatype questions

From: <hts_no_spam__at_core.no>
Date: Wed, 27 May 1998 11:04:55 +0200
Message-ID: <MPG.fd5f5a0ac940553989689_at_news.sol.no>


In article <6kfj2s$8i$1_at_seagoon.newcastle.edu.au>, cchln_at_alinga.newcastle.edu.au says...
> Hello-

Hello down under!
>
> I am new to Oracle and am not a database expert in general, so please
> excuse these questions if they seem obvious.
>
> I'm trying to get the data from an Access database I have been working on
> into Oracle tables so I can do things with it. I'm creating a table
> in Oracle with the same field names as my Access table, and same datatypes
> and linking to it in Access and then doing an append query to slurp the
> data
> into the Oracle table.
>
> My question is: where I have a counter/autonumber in Access, what
> is the equivalent Oracle datatype? I found ROWID, but I'm not sure if thi
> s
> is the same thing. Should I import the auto-numbered counter fields
> into Oracle as NUMBER and then change the datatype to ROWID? I bet that
> won't work... should I create an empty ROWID field in the Oracle table
> and not import any data in from Access, letting Oracle number it?

Rowid is internal to Oracle and you are better off not messing with it at this stage. Oracle does not have a direct equivalent to the autonumber columns of Access, sp you'll have to make the column NUMBER. To get something similar to 'autonumbering' in Oracle you'll have to use a SEQUENCE:

CREATE SEQUENCE my_sequence;
Look in the SQL reference manual for further options.

When you want to create a new number for your autonumber column you use something similar to this:

insert into my_table (my_autonumber_col,......) values(my_sequence.next_val,.....);

Remeber that if you already have data in your table that you took over from Access you'll want that sequence to start with a number bigger than your current max(my_autonumber_col). Use 'start with <number>' in your create sequence statement for this.

Hope this helps,
Haakon
Core Technology AS
www.core.no | hts_at_core.no Received on Wed May 27 1998 - 11:04:55 CEST

Original text of this message