Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
admin:basics:rawdata:delimited [2011/03/01 20:09]
els
— (current)
Line 1: Line 1:
-~~NOTOC~~ 
  
-{{page>:​top_add&​nofooter&​noeditbtn}} 
- 
-====== Administration:​ Omnidex Fundamentals ====== 
- 
-===== Raw Data Files ===== 
- 
-[[admin:​basics:​rawdata:​home|Overview]] | 
-[[admin:​basics:​rawdata:​fixed|Fixed-length Files]] | 
-**[[admin:​basics:​rawdata:​delimited|Delimited Files]]** | 
-[[admin:​basics:​rawdata:​layout|Record Layouts]] | 
-[[admin:​basics:​rawdata:​constraints|Table Constraints]] 
- 
----- 
-==== Delimited Files ==== 
- 
-Delimited files separate the content of columns and rows using special delimiter characters. ​ These are commonly used by relational databases and other data-related tools as a standard, portable data format. ​ Tabs and commas are the most common delimiters between columns, and linefeeds are the most common delimiters between rows.  Delimited files always store data in character format, though they can correlate to binary datatypes in a table definition.  ​ 
- 
-In the example below, each row consumes a variable amount of space, based on the actual length of the data.  Columns are separated by commas and rows are separated by linefeeds, so Omnidex will parse the file to read it as a table. ​ All data is stored in character format, including binary data such as the TAX_RATE.  ​ 
- 
-^Column\\ ​ Datatype ​ ^STATE\\ ​ CHAR(2) ​ ^DESCRIPTION\\ ​ STRING(31) ​ ^STATE_CODE\\ ​ CHAR(2) ​ ^REGION\\ ​ CHAR(2) ​ ^COUNTRY\\ ​ CHAR(2) ​ ^TAX_RATE\\ ​ FLOAT  ^ 
-^Row 1      |AK,​Alaska,​02,​PC,​US,​0.000 ​  ​|||||| 
-^Row 2      |AL,​Alabama,​01,​ES,​US,​4.000 ​ |||||| 
-^Row 3      |AR,​Arkansas,​05,​WS,​US,​4.625 |||||| 
- 
- 
-==== Declaring a Delimited File ==== 
- 
-Delimited files are accessed by creating a table definition in Omnidex that points to the data file.  Just like with fixed-length files, applications can then use SQL statements to access the table. ​ Omnidex will parse and read the data in the delimited file just like it would when accessing a relational table. 
- 
-In the [[dev:​sql:​statements:​create_table:​home|CREATE TABLE]] statement, the OPTIONS clause is used to identify this as a delimited file and indicate which delimiters to use.  An option of TAB_DELIMITED indicates a standard tab-delimited file; an option of COMMA_DELIMITED indicates a standard comma-delimited file; and an option of DELIMITED indicates a general delimited file with specifically named column and record delimiters. 
- 
-The PHYSICAL clause points to the physical location of the delimited file.  This PHYSICAL clause can contain a relative path name (relative to the location of the Omnidex Environment File) such as "​dat/​states.csv",​ or an absolute path name such as "​d:/​class/​lab1/​dat/​states.csv"​. ​ This PHYSICAL clause can also contain wildcard as described below, and can also reference [[appendix:​reference:​envvar|environment variables]] using a special syntax. 
- 
-<code sql> 
-create table          "​STATES"​ 
- ​options ​             "​COMMA_DELIMITED"​ 
- ​physical ​            "​dat/​states.csv"​ 
- ... 
-</​code>​ 
- 
-=== Options === 
- 
-The following options are allowed in the OPTIONS clause: 
- 
-Delimiter options: 
- ​COLUMN='​c'​ or COLUMN='​cc'​ 
- ​RECORD='​c'​ or RECORD='​cc'​ 
- 
-Quoting and escaping options: 
- ​QUOTES 
- ​ESCAPE='​c'​ 
- 
-Header row options: 
- ​HEADER 
- 
-== Delimiter options: COLUMN and RECORD == 
- 
-The COLUMN option indicates the delimiter used to separate columns in a row.  The RECORD option indicates the delimiter used to separate rows in a file.  Any one or two characters can be used.  For example, the syntax COLUMN='​|~'​ indicates that a combination of | and ~ adjacent to each other will delimit columns. ​ Unprintable characters can be used as well, and are specified using the tokens described below: 
- 
-^ Character ^ Description ​         ^ 
-| \a        | alert                | 
-| \b        | bell                 | 
-| \f        | formfeed ​            | 
-| \n        | linefeed ​            | 
-| \r        | carriage-return ​     | 
-| \t        | horizontal tab       | 
-| \v        | vertical tab         | 
-| %%\\%% ​   | backslash ​           | 
-| \' ​       | single-quote ​        | 
-| \nnn      | octal value          | 
-  ​ 
-The default column separator is a tab (eg. COLUMN='​\t'​). ​ The default record separator is a combination of carriage return and linefeed for Microsoft Windows servers (eg. RECORD='​\r\n'​),​ and a linefeed for UNIX servers (eg. RECORD='​\n'​). 
- 
-== Quoting and Escaping options: QUOTES and ESCAPE === 
- 
-Some delimited files will quote the content of some or all of the columns. ​ This insures that delimiter characters found in the data are not treated as actual delimiters. ​ For example, the column "​William Smith, Attorney at Law" is often quoted in a comma-delimited file so that the embedded comma is not treated as a delimiter. ​ In these cases, use the QUOTES option to interpret quotation marks as having this purpose, rather than being part of the data.  Quotes will be considered part of the data by default. 
- 
-As an alternative,​ delimited files may use an escape character to indicate that the subsequent character should not be considered a delimiter, but rather is part of the data.  Rather than quoting the data, an escape character precedes every occurrence of the delimiter in the data itself. ​ (Ironically,​ if the escape character itself exists in the data, then it too must be escaped using its own character.) ​ Escaping may be turned off using the OFF setting. ​ In this example, the default escape character of \ is used prevent commas and apostrophes from being considered delimiters: 
- 
-^Column\\ ​ Datatype ​ ^ID\\  INTEGER ​ ^COMPANY\\ ​ STRING(31) ​ ^ 
-^Row 1      |1,​Mabel\'​s Famous Diner            || 
-^Row 2      |2,William Smith\, Attorney at Law  || 
- 
-== Header row options: HEADER == 
- 
-The HEADER option indicates that the first row of the file contains column names rather than data and should be ignored when reading the table. 
- 
-==== Declaring Filesets ==== 
- 
-In the example above, a single file was used as the source of data for a table. ​ It is also possible for multiple files to be used as the source of data for a table. ​ As long as the files all share the same record layout, they will all be processed when reading the table. Filesets can be declared as a comma-separated list of files, or they can be declared using wildcards in the filename. ​ In this example, three files are declared individually in the PHYSICAL clause: 
- 
-<code sql> 
-create table          "​STATES"​ 
- ​physical ​            "​c:/​class/​lab1/​dat/​states1.dat, ​ 
-                       ​c:/​class/​lab1/​dat/​states2.dat, ​ 
-                       ​d:/​class/​lab1/​dat/​states3.dat"​ 
- ... 
-</​code>​ 
- 
-In this second example, wildcards are used to declare these files: 
- 
-<code sql> 
-create table          "​STATES"​ 
- ​physical ​            "​c:/​class/​lab1/​dat/​states*.dat, ​ 
-                       ​d:/​class/​lab1/​dat/​states*.dat"​ 
- ... 
-</​code>​ 
- 
-Files can reside in multiple directories and in multiple drives or volumes to allow a table to span multiple storage devices. ​ Files may also reside on a Storage Area Network (SAN); in fact, this is one of the most common implementations of Omnidex. ​ Files may also reside on simple mapped drives; however, users should expect performance degradation to occur in this scenario. ​ 
- 
-Wildcards provide a great flexibility since they allow more data to be added to a table by simply moving another file into place. ​ Care should be taken with this approach, though, since the table must be reindexed as soon as new data is in place. 
- 
- 
-==== Limitations of Fixed-length Files ==== 
- 
-Fixed-length files are often the highest performance and most flexible approach to indexing large amounts of data, but they do have some limitations. ​ These limitations are described below: 
- 
-  * **Datatypes** - Fixed-length files can store nearly every datatype supported by Omnidex, including proprietary datatypes such as ORACLE DATETIME or ODBC DATETIME. ​ Fixed-length files cannot support VARCHAR and CLOB class datatypes because these complex datatypes must be accompanied by length variables that indicate the exact length of the data within the column for each row.  STRING and CHARACTER datatypes should be used instead. 
- 
-  * **Deletes** - Omnidex supports INSERT and DELETE statements against fixed-length files, but it cannot support the DELETE statement. ​ If DELETE statements are required, consider using [[admin:​features:​ost:​home|Omnidex Standalone Tables]]. 
- 
-  * **Compression** - Fixed-length files require the same number of bytes per row, regardless of the content of the data.  This can lead to excessive use of disk space if tables have large textual columns. ​ For example, an email address column may be sized at 320 bytes, consistent with the published standard; however, most people have relatively short email addresses. ​ If the average email address is 24 characters long, then most rows will waste nearly 300 bytes. ​ This both wastes disk space and degrades performance. ​ In these situations, [[admin:​basics:​rawdata:​delimited|delimited files]] or [[admin:​features:​ost:​home|Omnidex Standalone Tables]] will provide a better solution. 
- 
-  * **Security** - Fixed-length data files are not encrypted as they might be in a relational database. ​ Care should be taken with file system security to properly protect the data. 
- 
- 
- 
-### 
-Omnidex supports a variety of configuration options for declaring delimited files: 
- 
-=== Column delimiters === 
-The delimiters ​ used can vary between files. ​ To accommodate this, Omnidex supports any one or two characters as column delimiters, and and one or two characters as record delimiters. ​ Omnidex also supports various configurations of quoting data and using escape characters to handle occurrences of the delimiter in the data itself. ​ 
- 
-The delimited files that Omnidex indexes must maintain a consistent structure, meaning that each row must use consistent delimiters and must have the same number of columns.  ​ 
- 
- 
- 
-=== Record delimiters === 
- 
- 
-=== Quotes === 
- 
- 
-=== Escape Character === 
- 
- 
-=== Header Row === 
- 
- 
-==== Offset Indexes ==== 
- 
-=====  ===== 
- 
-**[[admin:​basics:​rawdata:​home|Prev]]** | 
-**[[admin:​basics:​rawdata:​record|Next]]** 
- 
-====== Additional Resources ====== 
- 
-See also:  
- 
-{{page>:​admin:​basics:​see_also&​nofooter&​noeditbtn}} 
- 
-{{page>:​bottom_add&​nofooter&​noeditbtn}} 
 
Back to top
admin/basics/rawdata/delimited.1299010175.txt.gz ยท Last modified: 2012/10/26 14:51 (external edit)