The function list-attribute-types
returns type information for the attributes in the table given by table.
database has a default value of *default-database*.
If owner is nil
, only user-owned attributes are considered. This is the default.
If owner is :all
, all attributes are considered.
If owner is a string, this denotes a username and only attributes owned by owner are considered.
result is a list in which each element is a list (attribute datatype precision scale nullable). attribute is a string denoting the attribute name. datatype is the vendor-specific type as described in attribute-type. nullable is 1 if the attribute accepts the value NULL, and 0 otherwise.
When using ODBC to connect to Access database, the nullable value is not reliable, at least on version 7.1. There seems to be a bug in the driver. Using ODBC with other DBMS works as documented.
To print the type of every attribute in the database, do
(loop for tab in
(sql:list-tables)
do
(loop for type-info in
(sql:list-attribute-types tab)
do
(format t "~&Table ~S Attribute ~S Type ~S"
tab
(first type-info)
(second type-info))))
LispWorks User Guide and Reference Manual - 13 Feb 2015