Creating and dropping CONNECT Tables

You are viewing an old version of this article. View the current version here.

Create Table statements for “CONNECT” tables are standard MySQL create statements specifying “engine=CONNECT”. There are a few additional table and column options specific to CONNECT.

Table options:

(More options will likely be added to this list in future versions of the handler.)

Table OptionTypeDescription
TABLE_TYPEStringThe type of the external table: DOS, FIX, BIN, CSV, FMT, XML, INI, DBF, VEC, ODBC, MYSQL, TBL, DIR, WMI, MAC. PROXY, XCOL, OCCUR, PIVOT and EOM. Defaults to DOS.
FILE_NAMEStringThe file (path) name for all table types based on files. Can be absolute or relative to the current data directory.
XFILE_NAMEStringThe file (path) base name for a table index files. Can be absolute or relative to the data directory. Defaults to the file name.
TABNAMEStringThe target table or node for ODBC, MYSQL, XML or catalog tables.
TABLE_LISTStringThe comma separated list of a TBL table sub-tables.
DBNAMEStringThe target database for ODBC, MYSQL or catalog tables.
DATA_CHARSETStringThe character set used in the external file or data source.
SEP_CHARStringSpecifies the field separator character of a CSV tables.
QCHARStringSpecifies the character used for quoting some fields of a CSV table or the identifiers of an ODBC tables.
MODULEStringThe (path) name of the DLL or shared lib implementing the access of a non-standard (OEM) table type.
SUBTYPEStringThe subtype of an OEM table type.
CATFUNCStringThe catalog function used by a catalog table.
OPTION_LISTStringUsed to specify all other options not yet directly defined.
MAPPEDBooleanSpecifies whether “file mapping” is used to handle the table file.
HUGEBooleanTo specify that a table file can be larger than 2GB.
COMPRESSBooleanTrue if the data file is compressed. Defaults to NO.
SPLITBooleanTrue for a VEC table when each columns are in separate files.
READONLYBooleanTrue if the data file must not be modified or erased.
SEPINDEXBooleanWhen true, indexes are saved in separate files.
LRECLIntegerThe file record size (often calculated by default).
BLOCK_SIZEIntegerThe number of rows each block of FIX, BIN, DBF OR VEC tables contains. For an ODBC table this is the RowSet size option.
MULTIPLEIntegerUsed to specify multiple file tables.
HEADERIntegerApplies to CSV, VEC and HTML files. Its meaning depends on the table type.
QUOTEDIntegerThe level of quoting used in CSV table files.
ENDINGIntegerEnd of line length. Default to 1 for Unix/Linux and 2 for Windows.

Because CONNECT handles many table types; many table type specific options are not into the above list and must be entered using the OPTION_LIST option. The syntax to use is:

... option_list='opname1=opvalue1,opname2=opvalue2...'

Beware that no blanks should be inserted before or after the ‘=’ and ‘,’ characters. The option name is all that is between the start of the string or the last ‘,’ character and the next ‘=’ character, and the option value is all that is between this ‘=’ character and the next ‘,’ or end of string. For instance:

option_list='name=TABLE,coltype=HTML,attribute=border=1;cellpadding=5,headattr=bgcolor=yellow';

This defines four options, ‘name’, ‘coltype’, ‘attribute’, and ‘headattr’ with values ‘TABLE’, ‘HTML’, ‘border=1;cellpadding=5’, and ‘bgcolor=yellow’. The only restriction is that values cannot contain commas, but they can contain equal signs.

Column options:

Column OptionTypeDescription
FLAGIntegerAn integer value whose meaning depends on the table type.
FIELD_LENGTHIntegerSet the internal field length for DATE columns.
DATE_FORMATStringThe format indicating how a date is stored in the file.
FIELD_FORMATStringThe column format for some table types.
SPECIALStringThe name of the SPECIAL column that set this column value.

Note 1: Creating a CONNECT table based on file does not erase or create the file if the file name is specified in the CREATE TABLE statement (“outward” table). If the file does not exist, it will be populated by subsequent INSERT commands or by the “AS select statement” of the CREATE TABLE command. Unlike the CSV engine, CONNECT easily permits to create tables based on already existing files, for instance files made by other applications. However, if the file name is not specified, a file with a name defaulting to tabname.tabtype will be created in the data directory (“inward” table).

Note 2: Dropping a CONNECT table is done with a standard DROP statement. For outward tables, this drops only the CONNECT table definition but does not erase the corresponding data file and index files. Use DELETE or TRUNCATE to do so. This is contrary to data and index files of inward tables are erased on DROP like for other MariaDB engines.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.