Toad World® Forums

How to create sequences?

Hi,

I am a new biee to sql navigator.can some one let me know how to create a sequence for a table in sql navigator?
Is there a wizard available?or if need to write the query how we will be specifying the table name for which the sequence is generated?

Thanks in Advance!!

Hi Haritha,

We do have a sequence wizard in SQL Navigator, it’s called Sequence Editor. You can create a sequence with Sequence Editor by right-clicking the Sequences node in DB Navigator or DB Explorer and choosing Create.

To assign a sequence to a table column (i.e. to make a column auto-increment), if that’s what you want to do, you need to also use the Table Editor. In the Columns grid for your table, just enter the Default value for your column as .next, where is your sequence name; every time you add a new row to the table, it will be populated with the next value of the sequence.

Hope this helps,
Roman

Hi Roman,

Nice to see your reply !!
I have created the sequence but when trying to add it as the default value of the column in a table I am getting the following error.

Error: ORA-00984: column not allowed here

along with this I just want to know that whether the same sequence can be used for multiple tables if so whether it is going to be the increment separately for every table or increment for all the tables?

Regards,
h@r!

To use a value of a sequence in Oracle you have to use a “before insert trigger” (using .nextval).
You can use the same sequence for several tables if you do not want to repeat “ids” between them.

Thank you Filipe. Using a trigger is indeed a better idea. Also, thanks for correcting me: ‘nextval’ should be used rather than ‘next’.

Roman