Skip to content

Identity

Mathias Rangel Wulff edited this page Jun 12, 2015 · 4 revisions

Keyword IDENTITY, AUTO_INCREMENT, AUTOINCREMENT

Syntax:

    CREATE TABLE tableid (
        columnid typeid IDENTITY [(start [, step])]
    );

AlaSQL supports autoincrement feature:

    alasql('CREATE TABLE one (a INT AUTO_INCREMENT, b STRING)');
    alasql('INSERT INTO one (b) VALUES ("one"), ("two")');
    var res = alasql('SELECT * FROM one');
    // returns [{"a":1,"b":"one"},{"a":2,"b":"two"}]

Try this example in jsFiddle

By default AlaSQL the initial value is 1 and th step is 1, but you can change it:

    alasql('CREATE TABLE one (a INT IDENTITY(10,5), b STRING)');

See also: DEFAULT

Clone this wiki locally