Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: auto increment? 'enum' data type?
In article <86nu0t$8di$2_at_rd1936.quicknet.nl>,
remco-blaakmeer_at_quicknet.nl wrote:
> In article <86nr2e$jd$1_at_nnrp1.deja.com>,
> Otis Gospodnetic <otis_at_my-deja.com> writes:
> > In article <86m9ot$q99$1_at_nnrp1.deja.com>,
> > M. Armaghan Saqib <armaghan_at_yahoo.com> wrote:
> >> I just had a detailed answer to a similar question.
> >>
> >> a) Oracle does not support access/sqlserver like "Autonumber"
columns
> >> but supports a sequence object which you can "bind" to a table
column
> >> (number type) using a pre-insert trigger.
> >
> > I think I understand how this would be done...
> > 1) create sequence
> > 2) create trigger....
> > Now I'm not sure about the syntax for 2)
> > I'd like something like this:
> > CREATE TRIGGER trigger_foo
> > BEFORE INSERT
> > ON mytablename
> > CURRVAL + 1
> >
> > So that when I make 1st insert the PK of 'mytablename' gets value 1,
> > and when the second row is inserted the PK gets value of 2, and so
on.
>
> See this Sql*Plus transcript for an explanation:
Thanks!
This is VERY helpful!
Another basic question - how do I tell Oracle that I want to make
tables, triggers, sequences, etc. only in certain database's space?
At one point I did:
"CREATE DATABASE MYDBNAME"
while logged in as system/manager, and then later I issued:
"CREATE USER MYUSER IDENTIFIED BY MYPASS"
But I'm not sure how to 'tie' the two (user + database) together, so
that when I login as MYUSER/MYPASS using SQLPlus I get put into
MYDBNAME space, so that anything I create, alter, or drop is restricted
to MYDBNAME?
Like this?
>> sqlplus myuser/mypass_at_mydbname.mydomain.com
Like that?
After a login like above I get this error:
Error accessing PRODUCT_USER_PROFILE
Warning: Product user profile information not loaded!
You may need to run PUPBLD.SQL as SYSTEM
If I login like the following, then i don't get the error: >> sqlplus
SQL*Plus: Release 8.1.5.0.0 - Production on Thu Jan 27 11:22:57 2000 (c) Copyright 1999 Oracle Corporation. All rights reserved.
Enter user-name: myuser
Enter password:
Connected to:
...
...
Any ideas?
I did login using svrmgrl as system/manager and I run that PUPBLD.SQL,
but I still get the error...
Still waiting for my Oracle DBA book... :(
Many thanks,
Otis
> SQL> create table test_enum
> 2 (id number(5)
> 3 ,text varchar2(10)
> 4 ,constraint test_enum_pk primary key(id)
> 5 )
> 6 /
>
>
>
>
>
>
>
>
>
>
> ID TEXT
> ---------- ----------
> 1 TEST
>
>
>> > Synax question.
> > Got it.
>
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Jan 27 2000 - 10:26:18 CST
![]() |
![]() |