Creare ed eliminare le tabelle CONNECT
Le istruzioni CREATE TABLE sulle tabelle CONNECT sono dei normali comandi per MySQL che specificano "engine=CONNECT". Esistono delle opzioni aggiuntive per le tabelle e per le colonne.
Opzioni di tabella:
(Probabilmente nuove opzioni verranno aggiunte nelle future versioni dell'handler.)
Opzione | Tipo | Spiegazione |
---|---|---|
TABLE_TYPE | Stringa | Il tipo di tabella esterna: DOS, FIX, BIN, CSV, FMT, XML, INI, DBF, VEC, ODBC, MYSQL, TBL, DIR, WMI, MAC e EOM. Il preferinito è DOS. |
FILE_NAME | Stringa | Il nome e il percorso del file, per tutte le tabelle basate sui file. Può essere assoluto, oppure relativo rispetto alla directory dei dati corrente. |
XFILE_NAME | Stringa | Il nome e il percorso dei file degli indici. Può essere assoluto, oppure relativo rispetto alla directory dei dati corrente. Il predefinito è il nome del file. |
TABNAME | Stringa | La tabella di destinazione, o il nodo per le tabelle ODBC, MYSQL, XML e catalog. |
TABLE_LIST | Stringa | La liste, separata da virgole, delle sottotabelle di una tabella TBL. |
DBNAME | Stringa | Il database di destinazione per le tabelle ODBC, MYSQL e catalog. |
DATA_CHARSET | String | Il set di caratteri usato dal file o dalla sorgente dati. |
SEP_CHAR | String | Specifica il carattere che separa i campi per le tabelle CSV. |
QCHAR | String | Specifica il carattere usato per virgolettare alcuni campi di una tabella CSV o gli identificatori per le tabelle ODBC. |
MODULE | String | Il nome e il percorso della DLL o della libreria condivisa che implementa l'accesso a una tabella non-standard (OEM). |
SUBTYPE | String | Il sottotipo di una tabella OEM. |
CATFUNC | String | La funzione catalog usata in una tabella catalog. |
OPTION_LIST | String | Usato per specificare le altre opzioni che non sono direttamente definite. |
MAPPED | Boolean | Specifica se si usa il "file mapping" per gestire il file. |
HUGE | Boolean | Specifica che il file della tabella supera i 2GB. |
COMPRESS | Boolean | True if the data file is compressed. Defaults to NO. |
SPLIT | Boolean | True for a VEC table when each columns are in separate files. |
READONLY | Boolean | True if the data file must not be modified or erased. |
SEPINDEX | Boolean | When true, indexes are saved in separate files. |
LRECL | Integer | The file record size (often calculated by default). |
BLOCK_SIZE | Integer | The number of rows each block of FIX, BIN, DBF OR VEC tables contains. For an ODBC table this is the RowSet size option. |
MULTIPLE | Integer | Used to specify multiple file tables. |
HEADER | Integer | Applies to CSV, VEC and HTML files. Its meaning depends on the table type. |
QUOTED | Integer | The level of quoting used in CSV table files. |
ENDING | Integer | End 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 Option | Type | Description |
---|---|---|
FLAG | Integer | An integer value whose meaning depends on the table type. |
FIELD_LENGTH | Integer | Set the internal field length for DATE columns. |
DATE_FORMAT | String | The format indicating how a date is stored in the file. |
FIELD_FORMAT | String | The column format for some table types. |
SPECIAL | String | The 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: 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 3: 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.