Create table statement.
Syntax:
CREATE TABLE tableid;
CREATE TABLE tableid (
column type constraints, ...
);
alasql('CREATE TABLE star (� \
one INT DEFAULT 100, \
� two STRING,�\
three BOOL PRIMARY KEY�); \
');
alasql('CREATE TABLE flight (flightNo INT, fromCity STRING, toCity STRING)');
For tables with unknown columns skip column definition part:
alasql('CREATE TABLE one');
alasql('INSERT INTO one VALUES {a:1}');
You can define data types for each column.
Also you can use columns without [data types](Data Types):
alasql('CREATE DATABASE test252; USE test252;');
alasql('CREATE TABLE sqlite_sequence(name,seq)');
alasql('INSERT INTO sqlite_sequence VALUES (1,10)');
alasql('INSERT INTO sqlite_sequence VALUES ("one","ten")');
var res = alasql('SELECT * FROM sqlite_sequence');
returns:
[ { "name": 1, "seq": 10 }, { "name": "one", "seq": "ten" } ]
You can use the following types of constraints:
- AUTO_INCREMENT, AUTOINCREMENT, or IDENTITY
- CHECK
- [PRIMARY KEY](Primary Key)
- [FOREIGN KEY](Foreign Key)
See also: [DROP TABLE](Drop Table)