All Manuals > LispWorks User Guide and Reference Manual > 47 The SQL Package

NextPrevUpTopContentsIndex

create-table

Function
Summary

Creates a table.

Package

sql

Signature

create-table name description &key database type extra-options

Arguments

name

The name of the table.

description

The table properties.

database

A database.

type

A string or the keyword :support-transactions, or nil.

extra-options

A string or nil.

Values

None.

Description

The function create-table creates a table called name and defines its columns and other properties with description. The argument description is a list containing lists of attribute-name and type information pairs.

The default value of database is *default-database*.

type and extra-options are treated in a database-type specific way. Currently only database-type :mysql uses these options, as follows.

If type is not supplied, it defaults to the value (if any) of default-table-type that was supplied to connect. If extra-options is not supplied, it defaults to the value (if any) of default-table-extra-options that was supplied to connect.

type, if non-nil, is used as argument to TYPE in the SQL statement:

create table MyTable (column-specs) TYPE = type

except that if type is :support-transactions then create-table will attempt to make tables that support transactions, by using the type innodb.

extra-options (if non-nil) is appended in the end of this SQL statement.

When database-type is not :mysql, type and extra-options are ignored.

Example

The following code:

(create-table [manager]
  '(([id] (char 10) not-null)
    ([salary] (number 8 2))))

is equivalent to the following SQL:

CREATE TABLE MANAGER
   (ID CHAR(10) NOT NULL,SALARY NUMBER(8,2))
See also

connect
*default-database*
drop-table


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex