Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create Table

Mathias Rangel Wulff edited this pageJun 11, 2015 ·7 revisions

KeywordCREATE TABLE

Create table statement.

Syntax:

CREATETABLEtableid;CREATETABLEtableid (        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)');

Tables without column declarations

For tables with unknown columns skip column definition part:

alasql('CREATE TABLE one');alasql('INSERT INTO one VALUES {a:1}');

Columns data types

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")');varres=alasql('SELECT * FROM sqlite_sequence');

returns:

    [ {"name":1,"seq":10 }, {"name":"one","seq":"ten" } ]

Constraints

You can use the following types of constraints:

See also: [DROP TABLE](Drop Table)

© 2014-2026,Andrey Gershun &Mathias Rangel Wulff

Please help improve the documentation by opening a PR on thewiki repo

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp