Creare ed eliminare le tabelle CONNECT

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

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.)

OpzioneTipoSpiegazione
TABLE_TYPEStringaIl 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_NAMEStringaIl 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_NAMEStringaIl 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.
TABNAMEStringaLa tabella di destinazione, o il nodo per le tabelle ODBC, MYSQL, XML e catalog.
TABLE_LISTStringaLa liste, separata da virgole, delle sottotabelle di una tabella TBL.
DBNAMEStringaIl database di destinazione per le tabelle ODBC, MYSQL e catalog.
DATA_CHARSETStringIl set di caratteri usato dal file o dalla sorgente dati.
SEP_CHARStringSpecifica il carattere che separa i campi per le tabelle CSV.
QCHARStringSpecifica il carattere usato per virgolettare alcuni campi di una tabella CSV o gli identificatori per le tabelle ODBC.
MODULEStringIl nome e il percorso della DLL o della libreria condivisa che implementa l'accesso a una tabella non-standard (OEM).
SUBTYPEStringIl sottotipo di una tabella OEM.
CATFUNCStringLa funzione catalog usata in una tabella catalog.
OPTION_LISTStringUsato per specificare le altre opzioni che non sono direttamente definite.
MAPPEDBooleanSpecifica se si usa il "file mapping" per gestire il file.
HUGEBooleanSpecifica che il file della tabella supera i 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: 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.

Commenti

Sto caricando i commenti......
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.