Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: mysql to oracle migration
"Colm G. Connolly" <colmconn_at_nowhere.nocountry> wrote in message news:<newscache$nnyvsh$qt6$1_at_weblab.ucd.ie>...
> Hi all,
>
> I'm in the process of migrating to oracle (9.2.0.1.0) from Mysql and am
> having a few problems. Perhaps somebody might know how to solve them.
>
> 1. When I create my tables I try to create a column of boolean type but for
> some reason oracle doesn't like it. Should I just number(1) instead? (I've
> tried inhibitoryShunt boolean and inhibitoryShunt boolean default false)
Oracle doesn't support the Boolean datatype for columns :o( Yes, a NUMBER(1) with a check constraint like CHECK(col IN (0,1)) will do.
> 2. What are oracle equivalents of the MySql functions now() and
> last_insert_id()? I use them in the following contexts.
>
> insert into configurationMap values (NULL, 'MoreInhibition', now(), null);
>
> insert into tableMap values (NULL, last_insert_id(), 'afferentSynapses',
> last_insert_id())
now() -> SYSDATE
last_insert_id() as I understand it gives you the ID auto-generated by the preceding insert statement. Oracle doesn't have an exact equivalent - it doesn't do auto-increment columns. What Oracle has is an object called a SEQUENCE, with "methods" NEXTVAL and CURRVAL:
/* create sequence configurationSeq */
insert into configurationMap values (configurationSeq.NEXTVAL, 'MoreInhibition', SYSDATE, null);
insert into tableMap values (NULL, configurationSeq.CURRVAL, 'afferentSynapses', configurationSeq.CURRVAL); Received on Tue Feb 10 2004 - 10:21:26 CST