With this interface we do not envision the use of Prolog as a
database manager. Nevertheless, elementary access to the structure of a
database is required, for example to validate a database satisfies the
assumptions made by the application.
- odbc_current_table(+Connection,
-Table)
- Return on backtracking the names of all tables in the database
identified by the connection.
- odbc_current_table(+Connection,
?Table, ?Facet)
- Enumerate properties of the tables. Defines facets are:
- qualifier(Qualifier)
- owner(Owner)
- comment(Comment)
- These facets are defined by SQLTables()
- arity(Arity)
- This facet returns the number of columns in a table.
- odbc_table_column(+Connection,
?Table, ?Column)
- On backtracking, enumerate all columns in all tables.
- odbc_table_column(+Connection,
?Table, ?Column, ?Facet)
- Provides access to the properties of the table as defined by the ODBC
call SQLColumns(). Defined facets are:
- table_qualifier(Qualifier)
- table_owner(Owner)
- table_name(Table)
- See odbc_current_table/3.
- data_type(DataType)
- type_name(TypeName)
- precision(Precision)
- length(Length)
- scale(Scale)
- radix(Radix)
- nullable(Nullable)
- remarks(Remarks)
- These facets are defined by SQLColumns()
- type(Type)
- More prolog-friendly representation of the type properties. See
section 2.7.
- odbc_type(+Connection,
?TypeSpec, ?Facet)
- Query the types supported by the data source. TypeSpec is
either an integer type-id, the name of an ODBC SQL type or the constant
all_types
to enumerate all known types. This predicate
calls
SQLGetTypeInfo() and its facet names are derived from the
specification of this ODBC function:
- name(Name)
- Name used by the data-source. Use this in CREATE statements
- data_type(DataType)
- Numeric identifier of the type
- precision(Precision)
- When available, maximum precision of the type.
- literal_prefix(Prefix)
- When available, prefix for literal representation.
- literal_suffix(Suffix)
- When available, suffix for literal representation.
- create_params(CreateParams)
- When available, arguments needed to create the type.
- nullable(Bool)
- Whether the type can be
NULL
. May be unknown
- case_sensitive(Bool)
- Whether values for this type are case-sensitive.
- searchable(Searchable)
- Whether the type can be searched. Values are
false
,
true
, like_only
or all_except_like
.
- unsigned(Bool)
- When available, whether the value is signed. Please note that SWI-Prolog
does not provide unsigned integral values.
- money(Bool)
- Whether the type represents money.
- auto_increment(Bool)
- When available, whether the type can be auto-incremented.
- local_name(LocalName)
- Name of the type in local language.
- minimum_scale(MinScale)
- Minimum scale of the type.
- maximum_scale(MaxScale)
- Maximum scale of the type.
- odbc_table_primary_key(+Connection,
+Table, ?Column)
- True when Column is a primary key in Table.
- odbc_table_foreign_key(+Connection,
?PkTable, ?PkCol, ?FkTable, ?FkCol)
- True when PkTable/PkCol FkTable/FkCol
is a foreign keys column.