
i (I’m sure Oracle has some limitation on how big it can get, but I don’t know what that limit is).ģ. The “nomaxvalue” tells it to keep incrementing forever as opposed to resetting at some point. You could also replace it with “increment by n” if you want it to skip n-1 numbers between id numbers. The “increment by 1” clause is the default, so you could omit it. if you already have 213 entries in a table and you want to begin using this for your 214th entry, replace with “start with 214”). You could change “start with 1” to any number you want to begin with (e.g. Next we’ll create a sequence to use for the id numbers in our test table. (This is just a dumb quick example, so I won’t bother to specify any constraints on id.) create table test (id number, testdata varchar2(255)) Ģ. Let’s say we have a table called “test” with two columns, id and testdata. This is an extremely basic outline, so please try it first on a test table if you don’t know what you’re doing.ġ.

I find myself wanting to do this every now and then but not often enough that I remember the syntax from time to time, so I decided it was time to write myself up a little cheat sheet. Here is one way to do it by creating two database objects, a sequence and a trigger. You can do this easily in mysql by specifying “auto_increment” for your number, but Oracle makes you work a little more to get it done. Suppose you have a database and you want each entry to be identified by a unique number.
