There was an error while loading. Please reload this page.
Generates SQL command for CREATE TABLE.
sql.createTable(name, columns, [options]); // name: table name // columns: columns {name: type} // options: options {pk} // .pk: primary key (null => none)
const sql = require('extra-sql'); sql.createTable('plant', {name: 'TEXT', type: 'TEXT', age: 'INT'}); // CREATE TABLE IF NOT EXISTS "plant" ("name" TEXT, "type" TEXT, "age" INT); sql.createTable('animal', {name: 'TEXT', type: 'TEXT', age: 'INT'}, {pk: 'name'}); // CREATE TABLE IF NOT EXISTS "animal" ("name" TEXT, "type" TEXT, "age" INT, PRIMARY KEY("name"));