How to add an ID column to a table?

By creating a sequence object and adding it to the table.

ALTER TABLE ARTICLES<br />
  add(sekvenca number);<br />
/<br />
CREATE SEQUENCE seq_test<br />
START WITH 1<br />
INCREMENT BY 1<br />
MAXVALUE 9999999<br />
MINVALUE 1<br />
NOCYCLE;<br />
/<br />
UPDATE articles<br />
  SET seqvenca=seq_test.NEXTVAL;<br />
/<br />
SELECT code, name, seqvenca<br />
  FROM articles;<br />
/<br />

Leave a Reply

Your email address will not be published. Required fields are marked *