Function CREATE-TABLE — Create a database table.
Function
create-table name description &key database constraints transactions =>
The name of the table as a string, symbol or SQL expression.
A database object which defaults to *default-database*.
A list.
A string, a list of strings or NIL.
A Boolean. The default value is T.
Creates a table called name, which may be a string, symbol or SQL table identifier, in database which defaults to *default-database*. description is a list whose elements are lists containing the attribute names, types, and other constraints such as not-null or primary-key for each column in the table.
constraints is a string representing an SQL table constraint expression or a list of such strings.
With MySQL databases, if transactions is T an InnoDB table is created which supports transactions.
(create-table [foo] '(([id] integer) ([height] float) ([name] (string 24)) ([comments] longchar))) => (table-exists-p [foo]) => T (create-table [foo] '(([bar] integer :not-null :unique :primary-key) ([baz] string :not-null :unique))) => (table-exists-p [foo]) => T (create-table [foo] '(([bar] integer :not-null) ([baz] string :not-null)) :constraints '("UNIQUE (bar,baz)" "PRIMARY KEY (bar)")) => (table-exists-p [foo]) => T
A table is created in database.
*default-database*
An error is signalled if name is not a string, symbol or SQL expression. An error of type sql-database-data-error is signalled if a relation called name already exists.
The constraints and transactions keyword arguments to create-table are CLSQL extensions. The transactions keyword argument is for compatibility with MySQL databases.