Wiki page
[Virtual Tables (misc)] by
sandro
2018-08-22 12:40:22.
0000: 44 20 32 30 31 38 2d 30 38 2d 32 32 54 31 32 3a D 2018-08-22T12:
0010: 34 30 3a 32 32 2e 37 33 33 0a 4c 20 56 69 72 74 40:22.733.L Virt
0020: 75 61 6c 5c 73 54 61 62 6c 65 73 5c 73 28 6d 69 ual\sTables\s(mi
0030: 73 63 29 0a 50 20 36 33 30 31 62 65 36 35 61 61 sc).P 6301be65aa
0040: 64 64 31 34 31 61 36 32 37 61 34 31 34 39 39 66 dd141a627a41499f
0050: 33 35 35 65 33 66 31 32 65 39 64 38 66 62 0a 55 355e3f12e9d8fb.U
0060: 20 73 61 6e 64 72 6f 0a 57 20 31 39 34 32 33 0a sandro.W 19423.
0070: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f <a href="https:/
0080: 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 /www.gaia-gis.it
0090: 2f 66 6f 73 73 69 6c 2f 6c 69 62 73 70 61 74 69 /fossil/libspati
00a0: 61 6c 69 74 65 2f 68 6f 6d 65 22 3e 62 61 63 6b alite/home">back
00b0: 20 74 6f 20 6d 61 69 6e 20 70 61 67 65 3c 2f 61 to main page</a
00c0: 3e 0d 0a 3c 68 31 3e 3c 61 20 69 64 3d 22 56 69 >..<h1><a id="Vi
00d0: 72 74 75 61 6c 53 68 61 70 65 22 3e 56 69 72 74 rtualShape">Virt
00e0: 75 61 6c 53 68 61 70 65 3c 2f 61 3e 3c 2f 68 31 ualShape</a></h1
00f0: 3e 0d 0a 54 68 65 20 3c 62 3e 56 69 72 74 75 61 >..The <b>Virtua
0100: 6c 53 68 61 70 65 3c 2f 62 3e 20 49 6e 74 65 72 lShape</b> Inter
0110: 66 61 63 65 20 61 6c 6c 6f 77 73 20 74 6f 20 64 face allows to d
0120: 69 72 65 63 74 6c 79 20 61 63 63 65 73 73 20 61 irectly access a
0130: 6e 20 65 78 74 65 72 6e 61 6c 20 53 68 61 70 65 n external Shape
0140: 46 69 6c 65 20 62 79 20 75 73 69 6e 67 20 73 74 File by using st
0150: 61 6e 64 61 72 64 20 53 70 61 74 69 61 6c 20 53 andard Spatial S
0160: 51 4c 20 71 75 65 72 69 65 73 2e 3c 62 72 3e 0d QL queries.<br>.
0170: 0a 53 79 6e 74 61 78 20 66 6f 72 20 63 72 65 61 .Syntax for crea
0180: 74 69 6e 67 20 61 20 56 69 72 74 75 61 6c 53 68 ting a VirtualSh
0190: 61 70 65 20 54 61 62 6c 65 3a 0d 0a 3c 76 65 72 ape Table:..<ver
01a0: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 batim>..SELECT C
01b0: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA
01c0: 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 BLE my_table USI
01d0: 4e 47 20 56 69 72 74 75 61 6c 53 68 61 70 65 20 NG VirtualShape
01e0: 28 20 73 68 70 5f 70 61 74 68 20 2c 20 63 68 61 ( shp_path , cha
01f0: 72 73 65 74 5f 65 6e 63 6f 64 69 6e 67 20 2c 20 rset_encoding ,
0200: 73 72 69 64 20 29 3b 0d 0a 0d 0a 53 45 4c 45 43 srid );....SELEC
0210: 54 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c T CREATE VIRTUAL
0220: 20 54 41 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 TABLE my_table
0230: 55 53 49 4e 47 20 56 69 72 74 75 61 6c 53 68 61 USING VirtualSha
0240: 70 65 20 28 20 73 68 70 5f 70 61 74 68 20 2c 20 pe ( shp_path ,
0250: 63 68 61 72 73 65 74 5f 65 6e 63 6f 64 69 6e 67 charset_encoding
0260: 20 2c 20 73 72 69 64 20 2c 20 74 65 78 74 5f 64 , srid , text_d
0270: 61 74 65 73 20 29 3b 0d 0a 0d 0a 53 45 4c 45 43 ates );....SELEC
0280: 54 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c T CREATE VIRTUAL
0290: 20 54 41 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 TABLE my_table
02a0: 55 53 49 4e 47 20 56 69 72 74 75 61 6c 53 68 61 USING VirtualSha
02b0: 70 65 20 28 20 73 68 70 5f 70 61 74 68 20 2c 20 pe ( shp_path ,
02c0: 63 68 61 72 73 65 74 5f 65 6e 63 6f 64 69 6e 67 charset_encoding
02d0: 20 2c 20 73 72 69 64 20 2c 20 74 65 78 74 5f 64 , srid , text_d
02e0: 61 74 65 73 20 2c 20 63 6f 6c 6e 61 6d 65 5f 63 ates , colname_c
02f0: 61 73 65 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 ase );..</verbat
0300: 69 6d 3e 0d 0a 53 75 70 70 6f 72 74 65 64 20 61 im>..Supported a
0310: 72 67 75 6d 65 6e 74 73 20 61 6e 64 20 74 68 65 rguments and the
0320: 69 72 20 69 6e 74 65 72 70 72 65 74 61 74 69 6f ir interpretatio
0330: 6e 3a 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 n:..<ul>..<li><b
0340: 3e 73 68 70 5f 70 61 74 68 3c 2f 62 3e 20 28 3c >shp_path</b> (<
0350: 69 3e 3c 62 3e 6d 61 6e 64 61 74 6f 72 79 3c 2f i><b>mandatory</
0360: 62 3e 3c 2f 69 3e 29 3a 20 74 68 65 20 72 65 6c b></i>): the rel
0370: 61 74 69 76 65 20 6f 72 20 61 62 73 6f 6c 75 74 ative or absolut
0380: 65 20 70 61 74 68 6e 61 6d 65 20 6c 65 61 64 69 e pathname leadi
0390: 6e 67 20 74 6f 20 74 68 65 20 65 78 74 65 72 6e ng to the extern
03a0: 61 6c 20 53 68 61 70 65 66 69 6c 65 2e 0d 0a 3c al Shapefile...<
03b0: 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 4e 6f 74 65 ul>..<li><b>Note
03c0: 3c 2f 62 3e 3a 20 61 6e 79 20 53 68 61 70 65 66 </b>: any Shapef
03d0: 69 6c 65 20 72 65 71 75 69 72 65 73 20 61 74 20 ile requires at
03e0: 6c 65 61 73 74 20 74 68 72 65 65 20 69 6e 64 69 least three indi
03f0: 76 69 64 75 61 6c 20 6d 65 6d 62 65 72 73 20 73 vidual members s
0400: 68 61 72 69 6e 67 20 74 68 65 20 73 61 6d 65 20 haring the same
0410: 62 61 73 65 20 6e 61 6d 65 20 62 75 74 20 77 69 base name but wi
0420: 74 68 20 64 69 66 66 65 72 65 6e 74 20 73 75 66 th different suf
0430: 66 69 78 65 73 20 28 3c 69 3e 2a 2e 73 68 70 3c fixes (<i>*.shp<
0440: 2f 69 3e 2c 20 3c 69 3e 2a 2e 73 68 78 3c 2f 69 /i>, <i>*.shx</i
0450: 3e 20 61 6e 64 20 3c 69 3e 2a 2e 64 62 66 3c 2f > and <i>*.dbf</
0460: 69 3e 29 2e 3c 62 72 3e 0d 0a 41 6c 6c 20 73 75 i>).<br>..All su
0470: 66 66 69 78 65 73 20 77 69 6c 6c 20 62 65 20 61 ffixes will be a
0480: 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 68 61 6e utomatically han
0490: 64 6c 65 64 20 62 79 20 56 69 72 74 75 61 6c 53 dled by VirtualS
04a0: 68 61 70 65 2c 20 61 6e 64 20 63 6f 6e 73 65 71 hape, and conseq
04b0: 75 65 6e 74 6c 79 20 74 68 65 20 3c 62 3e 73 68 uently the <b>sh
04c0: 70 5f 70 61 74 68 3c 2f 62 3e 20 61 72 67 75 6d p_path</b> argum
04d0: 65 6e 74 20 3c 62 3e 3c 75 3e 3c 69 3e 6d 75 73 ent <b><u><i>mus
04e0: 74 20 6e 6f 74 20 73 70 65 63 69 66 79 20 61 6e t not specify an
04f0: 79 20 70 72 65 66 69 78 3c 2f 69 3e 3c 2f 75 3e y prefix</i></u>
0500: 3c 2f 62 3e 2c 20 6a 75 73 74 20 74 68 65 20 62 </b>, just the b
0510: 61 72 65 20 62 61 73 65 20 70 61 74 68 20 6d 75 are base path mu
0520: 73 74 20 62 65 20 70 61 73 73 65 64 2e 3c 2f 6c st be passed.</l
0530: 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a i>..</ul></li>..
0540: 3c 6c 69 3e 3c 62 3e 63 68 61 72 73 65 74 5f 65 <li><b>charset_e
0550: 6e 63 6f 64 69 6e 67 3c 2f 62 3e 20 28 3c 69 3e ncoding</b> (<i>
0560: 3c 62 3e 6d 61 6e 64 61 74 6f 72 79 3c 2f 62 3e <b>mandatory</b>
0570: 3c 2f 69 3e 29 3a 20 63 61 6e 6f 6e 69 63 61 6c </i>): canonical
0580: 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 63 68 61 name of the cha
0590: 72 73 65 74 20 65 6e 63 6f 64 69 6e 67 20 61 64 rset encoding ad
05a0: 6f 70 74 65 64 20 62 79 20 74 68 65 20 3c 62 3e opted by the <b>
05b0: 44 42 46 3c 2f 62 3e 20 6d 65 6d 62 65 72 2e 0d DBF</b> member..
05c0: 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 45 78 61 6d 70 .<ul>..<li>Examp
05d0: 6c 65 73 20 6f 66 20 76 61 6c 69 64 20 6e 61 6d les of valid nam
05e0: 65 73 20 61 72 65 3a 20 3c 62 3e 41 53 43 49 49 es are: <b>ASCII
05f0: 3c 2f 62 3e 2c 20 3c 62 3e 55 54 46 2d 38 3c 2f </b>, <b>UTF-8</
0600: 62 3e 2c 20 3c 62 3e 43 50 38 35 30 3c 2f 62 3e b>, <b>CP850</b>
0610: 2c 20 3c 62 3e 49 53 4f 2d 38 38 34 39 2d 31 3c , <b>ISO-8849-1<
0620: 2f 62 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 59 6f /b></li>..<li>Yo
0630: 75 20 63 61 6e 20 63 68 65 63 6b 20 74 68 65 20 u can check the
0640: 66 75 6c 6c 20 6c 69 73 74 20 6f 66 20 73 75 70 full list of sup
0650: 70 6f 72 74 65 64 20 63 68 61 72 73 65 74 20 65 ported charset e
0660: 6e 63 6f 64 69 6e 67 73 20 66 72 6f 6d 20 3c 61 ncodings from <a
0670: 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 href="https://w
0680: 77 77 2e 67 6e 75 2e 6f 72 67 2f 73 6f 66 74 77 ww.gnu.org/softw
0690: 61 72 65 2f 6c 69 62 69 63 6f 6e 76 2f 22 3e 68 are/libiconv/">h
06a0: 65 72 65 3c 2f 61 3e 2e 3c 2f 6c 69 3e 0d 0a 3c ere</a>.</li>..<
06b0: 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c /ul></li>..<li><
06c0: 62 3e 73 72 69 64 3c 2f 62 3e 20 28 3c 69 3e 3c b>srid</b> (<i><
06d0: 62 3e 6d 61 6e 64 61 74 6f 72 79 3c 2f 62 3e 3c b>mandatory</b><
06e0: 2f 69 3e 29 3a 20 74 68 65 20 53 52 49 44 20 76 /i>): the SRID v
06f0: 61 6c 75 65 20 6f 66 20 61 6c 6c 20 47 65 6f 6d alue of all Geom
0700: 65 74 72 69 65 73 20 77 69 74 68 69 6e 20 74 68 etries within th
0710: 65 20 53 68 61 70 65 66 69 6c 65 2e 0d 0a 3c 75 e Shapefile...<u
0720: 6c 3e 0d 0a 3c 6c 69 3e 45 78 61 6d 70 6c 65 73 l>..<li>Examples
0730: 20 6f 66 20 76 61 6c 69 64 20 53 52 49 44 20 76 of valid SRID v
0740: 61 6c 75 65 73 20 61 72 65 3a 20 3c 62 3e 34 33 alues are: <b>43
0750: 32 36 3c 2f 62 3e 2c 20 3c 62 3e 33 30 30 33 3c 26</b>, <b>3003<
0760: 2f 62 3e 2c 20 3c 62 3e 33 32 36 33 32 3c 2f 62 /b>, <b>32632</b
0770: 3e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c ></li>..</ul></l
0780: 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e 74 65 78 74 5f i>..<li><b>text_
0790: 64 61 74 65 73 3c 2f 62 3e 20 28 3c 69 3e 3c 62 dates</b> (<i><b
07a0: 3e 6f 70 74 69 6f 6e 61 6c 3c 2f 62 3e 3c 2f 69 >optional</b></i
07b0: 3e 29 3a 20 74 68 69 73 20 69 73 20 61 20 3c 62 >): this is a <b
07c0: 3e 42 4f 4f 4c 45 41 4e 3c 2f 62 3e 20 66 6c 61 >BOOLEAN</b> fla
07d0: 67 3a 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 69 66 g:..<ul>..<li>if
07e0: 20 73 65 74 20 74 6f 20 3c 62 3e 30 3c 2f 62 3e set to <b>0</b>
07f0: 20 28 3c 62 3e 46 41 4c 53 45 3c 2f 62 3e 29 20 (<b>FALSE</b>)
0800: 61 6c 6c 20 66 69 65 6c 64 73 20 6f 66 20 74 68 all fields of th
0810: 65 20 3c 62 3e 44 41 54 45 3c 2f 62 3e 20 74 79 e <b>DATE</b> ty
0820: 70 65 20 77 69 6c 6c 20 62 65 20 72 65 70 72 65 pe will be repre
0830: 73 65 6e 74 65 64 20 61 73 20 3c 61 20 68 72 65 sented as <a hre
0840: 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 73 f="https://www.s
0850: 71 6c 69 74 65 2e 6f 72 67 2f 6c 61 6e 67 5f 64 qlite.org/lang_d
0860: 61 74 65 66 75 6e 63 2e 68 74 6d 6c 22 3e 6a 75 atefunc.html">ju
0870: 6c 69 61 6e 20 64 61 74 65 73 3c 2f 61 3e 3c 2f lian dates</a></
0880: 6c 69 3e 0d 0a 3c 6c 69 3e 69 66 20 73 65 74 20 li>..<li>if set
0890: 74 6f 20 61 6e 79 20 6f 74 68 65 72 20 69 6e 74 to any other int
08a0: 65 67 65 72 20 76 61 6c 75 65 20 28 3c 62 3e 54 eger value (<b>T
08b0: 52 55 45 3c 2f 62 3e 29 20 61 6c 6c 20 66 69 65 RUE</b>) all fie
08c0: 6c 64 73 20 6f 66 20 74 68 65 20 3c 62 3e 44 41 lds of the <b>DA
08d0: 54 45 3c 2f 62 3e 20 74 79 70 65 20 77 69 6c 6c TE</b> type will
08e0: 20 62 65 20 72 65 70 72 65 73 65 6e 74 65 64 20 be represented
08f0: 61 73 20 54 65 78 74 20 53 74 72 69 6e 67 73 20 as Text Strings
0900: 61 73 20 65 2e 67 2e 20 3c 62 3e 32 30 31 38 2d as e.g. <b>2018-
0910: 30 38 2d 32 31 3c 2f 62 3e 3c 2f 6c 69 3e 0d 0a 08-21</b></li>..
0920: 3c 6c 69 3e 69 66 20 6e 6f 74 20 65 78 70 6c 69 <li>if not expli
0930: 63 69 74 6c 79 20 73 70 65 63 69 66 69 65 64 2c citly specified,
0940: 20 3c 62 3e 54 52 55 45 3c 2f 62 3e 20 77 69 6c <b>TRUE</b> wil
0950: 6c 20 61 6c 77 61 79 73 20 62 65 20 61 73 73 75 l always be assu
0960: 6d 65 64 20 28 64 65 66 61 75 6c 74 20 73 65 74 med (default set
0970: 74 69 6e 67 29 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 ting).</li>..</u
0980: 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e l></li>..<li><b>
0990: 63 6f 6c 6e 61 6d 65 5f 63 61 73 65 3c 2f 62 3e colname_case</b>
09a0: 20 28 3c 69 3e 3c 62 3e 6f 70 74 69 6f 6e 61 6c (<i><b>optional
09b0: 3c 2f 62 3e 3c 2f 69 3e 29 3a 20 74 68 69 73 20 </b></i>): this
09c0: 61 72 67 75 6d 65 6e 74 20 73 70 65 63 69 66 69 argument specifi
09d0: 65 73 20 69 66 20 61 6c 6c 20 63 6f 6c 75 6d 6e es if all column
09e0: 20 6e 61 6d 65 73 20 73 68 6f 75 6c 64 20 62 65 names should be
09f0: 20 63 6f 6e 73 69 64 65 72 65 64 20 75 70 70 65 considered uppe
0a00: 72 63 61 73 65 20 6f 72 20 6c 6f 77 65 72 63 61 rcase or lowerca
0a10: 73 65 2e 3c 62 72 3e 0d 0a 56 61 6c 69 64 20 73 se.<br>..Valid s
0a20: 65 74 74 69 6e 67 73 20 61 72 65 3a 0d 0a 3c 75 ettings are:..<u
0a30: 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 75 70 70 65 72 l>..<li><b>upper
0a40: 63 61 73 65 3c 2f 62 3e 20 6f 72 20 3c 62 3e 75 case</b> or <b>u
0a50: 70 70 65 72 3c 2f 62 3e 3a 20 61 6c 6c 20 63 6f pper</b>: all co
0a60: 6c 75 6d 6e 20 6e 61 6d 65 73 20 77 69 6c 6c 20 lumn names will
0a70: 62 65 20 66 75 6c 6c 79 20 63 61 70 69 74 61 6c be fully capital
0a80: 69 7a 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e ized.</li>..<li>
0a90: 3c 62 3e 6c 6f 77 65 72 63 61 73 65 3c 2f 62 3e <b>lowercase</b>
0aa0: 20 6f 72 20 3c 62 3e 6c 6f 77 65 72 3c 2f 62 3e or <b>lower</b>
0ab0: 3a 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e 61 6d : all column nam
0ac0: 65 73 20 77 69 6c 6c 20 62 65 20 66 75 6c 6c 20 es will be full
0ad0: 6c 6f 77 65 72 63 61 73 65 2e 3c 2f 6c 69 3e 0d lowercase.</li>.
0ae0: 0a 3c 6c 69 3e 3c 62 3e 73 61 6d 65 63 61 73 65 .<li><b>samecase
0af0: 3c 2f 62 3e 20 6f 72 20 3c 62 3e 73 61 6d 65 3c </b> or <b>same<
0b00: 2f 62 3e 3a 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 /b>: all column
0b10: 6e 61 6d 65 73 20 77 69 6c 6c 20 62 65 20 65 78 names will be ex
0b20: 61 63 74 6c 79 20 70 72 65 73 65 72 76 65 64 20 actly preserved
0b30: 61 73 20 74 68 65 79 20 61 72 65 20 64 65 66 69 as they are defi
0b40: 6e 65 64 20 69 6e 74 6f 20 74 68 65 20 44 42 46 ned into the DBF
0b50: 20 6d 65 6d 65 62 65 72 2e 3c 2f 6c 69 3e 0d 0a memeber.</li>..
0b60: 3c 6c 69 3e 69 66 20 6e 6f 74 20 73 70 65 63 69 <li>if not speci
0b70: 66 69 65 64 2c 20 6f 72 20 69 66 20 61 6e 79 20 fied, or if any
0b80: 6f 74 68 65 72 20 64 65 66 69 6e 69 74 69 6f 6e other definition
0b90: 20 64 65 66 69 6e 69 74 69 6f 6e 20 69 73 20 66 definition is f
0ba0: 6f 75 6e 64 2c 20 3c 62 3e 6c 6f 77 65 72 63 61 ound, <b>lowerca
0bb0: 73 65 3c 2f 62 3e 20 77 69 6c 6c 20 61 6c 77 61 se</b> will alwa
0bc0: 79 73 20 62 65 20 61 73 73 75 6d 65 64 20 28 64 ys be assumed (d
0bd0: 65 66 61 75 6c 74 20 73 65 74 74 69 6e 67 29 2e efault setting).
0be0: 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 </li>..</ul></li
0bf0: 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 74 >..</ul><br>..<t
0c00: 61 62 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 23 66 able bgcolor="#f
0c10: 66 66 66 64 30 22 20 63 65 6c 6c 70 61 64 64 69 fffd0" cellpaddi
0c20: 6e 67 3d 22 31 38 22 3e 3c 74 72 3e 3c 74 64 3e ng="18"><tr><td>
0c30: 0d 0a 3c 62 3e 4e 6f 74 65 3c 2f 62 3e 3a 20 71 ..<b>Note</b>: q
0c40: 75 6f 74 69 6e 67 20 6f 72 20 6e 6f 74 20 61 6e uoting or not an
0c50: 79 20 54 65 78 74 20 53 74 72 69 6e 67 20 77 68 y Text String wh
0c60: 65 6e 20 69 74 20 61 70 70 65 61 72 73 20 61 73 en it appears as
0c70: 20 61 20 56 69 72 74 75 61 6c 20 54 61 62 6c 65 a Virtual Table
0c80: 20 61 72 67 75 6d 65 6e 74 20 68 61 73 20 61 62 argument has ab
0c90: 73 6f 6c 75 74 65 6c 79 20 6e 6f 20 65 66 66 65 solutely no effe
0ca0: 63 74 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d ct...<verbatim>.
0cb0: 0a 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 .SELECT CREATE V
0cc0: 49 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f IRTUAL TABLE my_
0cd0: 74 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 table USING Virt
0ce0: 75 61 6c 53 68 61 70 65 28 20 2f 68 6f 6d 65 2f ualShape( /home/
0cf0: 73 61 6e 64 72 6f 2f 6d 79 73 68 70 20 2c 20 43 sandro/myshp , C
0d00: 50 31 32 35 32 20 2c 20 33 30 30 33 20 2c 20 31 P1252 , 3003 , 1
0d10: 20 2c 20 6c 6f 77 65 72 20 29 3b 0d 0a 6f 72 0d , lower );..or.
0d20: 0a 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 .SELECT CREATE V
0d30: 49 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f IRTUAL TABLE my_
0d40: 74 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 table USING Virt
0d50: 75 61 6c 53 68 61 70 65 28 20 27 2f 68 6f 6d 65 ualShape( '/home
0d60: 2f 73 61 6e 64 72 6f 2f 6d 79 73 68 70 27 20 2c /sandro/myshp' ,
0d70: 20 27 43 50 31 32 35 32 27 20 2c 20 33 30 30 33 'CP1252' , 3003
0d80: 20 2c 20 31 20 2c 20 27 6c 6f 77 65 72 27 20 29 , 1 , 'lower' )
0d90: 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a ;..</verbatim>..
0da0: 42 6f 74 68 20 6e 6f 74 61 74 69 6f 6e 73 20 77 Both notations w
0db0: 69 6c 6c 20 70 72 6f 64 75 63 65 20 65 78 61 63 ill produce exac
0dc0: 74 6c 79 20 74 68 65 20 73 61 6d 65 20 69 64 65 tly the same ide
0dd0: 6e 74 69 63 61 6c 20 72 65 73 75 6c 74 2e 0d 0a ntical result...
0de0: 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c </td></tr></tabl
0df0: 65 3e 0d 0a 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 e>..<br>..<table
0e00: 20 62 67 63 6f 6c 6f 72 3d 22 23 64 30 66 66 64 bgcolor="#d0ffd
0e10: 30 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 0" cellpadding="
0e20: 31 38 22 3e 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 68 18"><tr><td>..<h
0e30: 33 3e 42 65 73 74 20 70 72 61 63 74 69 63 65 73 3>Best practices
0e40: 20 61 6e 64 20 6b 6e 6f 77 6e 20 6c 69 6d 69 74 and known limit
0e50: 61 74 69 6f 6e 73 3c 2f 68 33 3e 0d 0a 3c 75 6c ations</h3>..<ul
0e60: 3e 0d 0a 3c 6c 69 3e 56 69 72 74 75 61 6c 20 54 >..<li>Virtual T
0e70: 61 62 6c 65 73 20 61 72 65 20 6e 6f 74 20 72 65 ables are not re
0e80: 61 6c 6c 79 20 67 65 6e 75 69 6e 65 20 44 61 74 ally genuine Dat
0e90: 61 62 61 73 65 20 54 61 62 6c 65 73 2c 20 74 68 abase Tables, th
0ea0: 65 79 20 61 72 65 20 6a 75 73 74 20 70 72 65 74 ey are just pret
0eb0: 65 6e 64 69 6e 67 20 74 6f 20 62 65 2e 3c 2f 6c ending to be.</l
0ec0: 69 3e 0d 0a 3c 6c 69 3e 56 69 72 74 75 61 6c 20 i>..<li>Virtual
0ed0: 54 61 62 6c 65 73 20 68 61 76 65 20 76 65 72 79 Tables have very
0ee0: 20 70 6f 6f 72 20 73 70 65 65 64 20 70 65 72 66 poor speed perf
0ef0: 6f 72 6d 61 6e 63 65 73 20 77 68 65 6e 20 63 6f ormances when co
0f00: 6d 70 61 72 65 64 20 74 6f 20 67 65 6e 75 69 6e mpared to genuin
0f10: 65 20 44 61 74 61 62 61 73 65 20 54 61 62 6c 65 e Database Table
0f20: 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 43 6f 6d s.</li>..<li>Com
0f30: 70 6c 65 78 20 53 51 4c 20 71 75 65 72 69 65 73 plex SQL queries
0f40: 20 3c 62 3e 4a 4f 49 4e 3c 2f 62 3e 69 6e 67 20 <b>JOIN</b>ing
0f50: 73 65 76 65 72 61 6c 20 54 61 62 6c 65 73 20 63 several Tables c
0f60: 61 6e 20 6f 66 74 65 6e 20 72 65 74 75 72 6e 20 an often return
0f70: 6f 64 64 20 61 6e 64 20 6d 69 73 6c 65 61 64 69 odd and misleadi
0f80: 6e 67 20 72 65 73 75 6c 74 73 65 74 73 2c 20 69 ng resultsets, i
0f90: 66 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 6f 66 f one or more of
0fa0: 20 74 68 65 20 3c 62 3e 4a 4f 49 4e 3c 2f 62 3e the <b>JOIN</b>
0fb0: 65 64 20 54 61 62 6c 65 73 20 61 72 65 20 6f 66 ed Tables are of
0fc0: 20 74 68 65 20 56 69 72 74 75 61 6c 20 74 79 70 the Virtual typ
0fd0: 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 54 68 65 e.</li>..<li>The
0fe0: 20 62 65 73 74 20 75 73 61 67 65 20 79 6f 75 20 best usage you
0ff0: 63 61 6e 20 64 6f 20 6f 66 20 61 20 56 69 72 74 can do of a Virt
1000: 75 61 6c 20 54 61 62 6c 65 20 69 73 20 74 6f 20 ual Table is to
1010: 6a 75 73 74 20 73 75 70 70 6f 72 74 20 62 61 73 just support bas
1020: 69 63 20 64 61 74 61 20 69 6d 70 6f 72 74 20 70 ic data import p
1030: 72 6f 63 65 73 73 65 73 2c 20 6f 72 20 74 6f 20 rocesses, or to
1040: 71 75 69 63 6b 6c 79 20 67 65 74 20 61 6e 20 6f quickly get an o
1050: 76 65 72 61 6c 6c 20 67 6c 61 6e 63 65 20 61 74 verall glance at
1060: 20 61 20 66 75 6c 6c 20 64 61 74 61 73 65 74 20 a full dataset
1070: 77 69 74 68 6f 75 74 20 6e 65 63 65 73 73 61 72 without necessar
1080: 69 6c 79 20 69 6d 70 6f 72 74 69 6e 67 20 69 74 ily importing it
1090: 20 69 6e 74 6f 20 74 68 65 20 44 61 74 61 62 61 into the Databa
10a0: 73 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 50 72 se.</li>..<li>Pr
10b0: 65 74 65 6e 64 69 6e 67 20 74 6f 20 75 73 65 20 etending to use
10c0: 61 20 56 69 72 74 75 61 6c 20 54 61 62 6c 65 20 a Virtual Table
10d0: 61 73 20 61 20 66 75 6c 6c 20 72 65 70 6c 61 63 as a full replac
10e0: 65 6d 65 6e 74 20 6f 66 20 69 6d 70 6f 72 74 69 ement of importi
10f0: 6e 67 20 61 6c 6c 20 64 61 74 61 20 77 69 74 68 ng all data with
1100: 69 6e 20 61 20 67 65 6e 75 69 6e 65 20 44 61 74 in a genuine Dat
1110: 61 62 61 73 65 20 54 61 62 6c 65 20 69 73 20 73 abase Table is s
1120: 74 72 6f 6e 67 6c 79 20 64 69 73 63 6f 75 72 61 trongly discoura
1130: 67 65 64 2c 20 61 6e 64 20 6e 65 76 65 72 20 69 ged, and never i
1140: 73 20 61 20 73 6d 61 72 74 20 69 64 65 61 2e 3c s a smart idea.<
1150: 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d /li>..</ul><br>.
1160: 0a 3c 62 3e 57 61 72 6e 69 6e 67 3c 2f 62 3e 3a .<b>Warning</b>:
1170: 20 56 69 72 74 75 61 6c 53 68 61 70 65 20 54 61 VirtualShape Ta
1180: 62 6c 65 73 20 61 72 65 20 61 6c 77 61 79 73 20 bles are always
1190: 73 75 62 6a 65 63 74 20 74 6f 20 3c 62 3e 52 45 subject to <b>RE
11a0: 41 44 2d 4f 4e 4c 59 3c 2f 62 3e 20 72 65 73 74 AD-ONLY</b> rest
11b0: 72 69 63 74 69 6f 6e 73 2e 20 41 6e 79 20 61 74 rictions. Any at
11c0: 74 65 6d 70 74 6f 20 74 6f 20 65 78 65 63 75 74 tempto to execut
11d0: 65 20 61 6e 20 3c 62 3e 49 4e 53 45 52 54 3c 2f e an <b>INSERT</
11e0: 62 3e 2c 20 3c 62 3e 55 50 44 41 54 45 3c 2f 62 b>, <b>UPDATE</b
11f0: 3e 20 6f 72 20 3c 62 3e 44 45 4c 45 54 45 3c 2f > or <b>DELETE</
1200: 62 3e 20 73 74 61 74 65 6d 65 6e 74 20 77 69 6c b> statement wil
1210: 6c 20 61 6c 77 61 79 73 20 72 65 74 75 72 6e 20 l always return
1220: 61 6e 20 65 72 72 6f 72 2e 3c 62 72 3e 0d 0a 3c an error.<br>..<
1230: 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 /td></tr></table
1240: 3e 0d 0a 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 >..<br>..<table
1250: 62 67 63 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 bgcolor="#e0e0e0
1260: 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 31 " cellpadding="1
1270: 38 22 3e 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 68 33 8"><tr><td>..<h3
1280: 3e 52 65 6c 61 74 65 64 20 54 6f 70 69 63 73 3c >Related Topics<
1290: 2f 68 33 3e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e /h3>..<ul>..<li>
12a0: 54 68 65 20 3c 62 3e 49 6d 70 6f 72 74 53 48 50 The <b>ImportSHP
12b0: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 ()</b> SQL funct
12c0: 69 6f 6e 20 61 6c 6c 6f 77 73 20 74 6f 20 63 72 ion allows to cr
12d0: 65 61 74 65 20 61 6e 64 20 70 6f 70 75 6c 61 74 eate and populat
12e0: 65 20 61 20 67 65 6e 75 69 6e 65 20 53 70 61 74 e a genuine Spat
12f0: 69 61 6c 20 54 61 62 6c 65 20 62 79 20 69 6d 70 ial Table by imp
1300: 6f 72 74 69 6e 67 20 61 6e 20 65 78 74 65 72 6e orting an extern
1310: 61 6c 20 53 68 61 70 65 66 69 6c 65 2e 3c 2f 6c al Shapefile.</l
1320: 69 3e 0d 0a 3c 6c 69 3e 41 6e 64 20 74 68 65 20 i>..<li>And the
1330: 3c 62 3e 45 78 70 6f 72 74 53 48 50 28 29 3c 2f <b>ExportSHP()</
1340: 62 3e 20 73 69 73 74 65 72 20 66 75 6e 63 74 69 b> sister functi
1350: 6f 6e 20 61 6c 6c 6f 77 73 20 74 6f 20 64 69 72 on allows to dir
1360: 65 63 74 6c 79 20 65 78 70 6f 72 74 20 61 20 77 ectly export a w
1370: 68 6f 6c 65 20 53 70 61 74 69 61 6c 20 54 61 62 hole Spatial Tab
1380: 6c 65 20 69 6e 74 6f 20 61 6e 20 65 78 74 65 72 le into an exter
1390: 6e 61 6c 20 53 68 61 70 65 66 69 6c 65 2e 3c 2f nal Shapefile.</
13a0: 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 2f 74 64 li>..</ul>..</td
13b0: 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 0d 0a ></tr></table>..
13c0: 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68 31 3e <br>..<hr>..<h1>
13d0: 3c 61 20 69 64 3d 22 56 69 72 74 75 61 6c 44 42 <a id="VirtualDB
13e0: 46 22 3e 56 69 72 74 75 61 6c 44 42 46 3c 2f 61 F">VirtualDBF</a
13f0: 3e 3c 2f 68 31 3e 0d 0a 54 68 65 20 3c 62 3e 56 ></h1>..The <b>V
1400: 69 72 74 75 61 6c 44 42 46 3c 2f 62 3e 20 49 6e irtualDBF</b> In
1410: 74 65 72 66 61 63 65 20 61 6c 6c 6f 77 73 20 74 terface allows t
1420: 6f 20 64 69 72 65 63 74 6c 79 20 61 63 63 65 73 o directly acces
1430: 73 20 61 6e 20 65 78 74 65 72 6e 61 6c 20 44 42 s an external DB
1440: 46 20 74 61 62 6c 65 20 62 79 20 75 73 69 6e 67 F table by using
1450: 20 73 74 61 6e 64 61 72 64 20 53 70 61 74 69 61 standard Spatia
1460: 6c 20 53 51 4c 20 71 75 65 72 69 65 73 2e 3c 62 l SQL queries.<b
1470: 72 3e 0d 0a 53 79 6e 74 61 78 20 66 6f 72 20 63 r>..Syntax for c
1480: 72 65 61 74 69 6e 67 20 61 20 56 69 72 74 75 61 reating a Virtua
1490: 6c 44 62 66 20 54 61 62 6c 65 3a 0d 0a 3c 76 65 lDbf Table:..<ve
14a0: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 rbatim>..SELECT
14b0: 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 CREATE VIRTUAL T
14c0: 41 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 ABLE my_table US
14d0: 49 4e 47 20 56 69 72 74 75 61 6c 44 62 66 20 28 ING VirtualDbf (
14e0: 20 64 62 66 5f 70 61 74 68 20 2c 20 63 68 61 72 dbf_path , char
14f0: 73 65 74 5f 65 6e 63 6f 64 69 6e 67 20 29 3b 0d set_encoding );.
1500: 0a 0d 0a 53 45 4c 45 43 54 20 43 52 45 41 54 45 ...SELECT CREATE
1510: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 6d VIRTUAL TABLE m
1520: 79 5f 74 61 62 6c 65 20 55 53 49 4e 47 20 56 69 y_table USING Vi
1530: 72 74 75 61 6c 44 62 66 20 28 20 64 62 66 5f 70 rtualDbf ( dbf_p
1540: 61 74 68 20 2c 20 63 68 61 72 73 65 74 5f 65 6e ath , charset_en
1550: 63 6f 64 69 6e 67 20 2c 20 74 65 78 74 5f 64 61 coding , text_da
1560: 74 65 73 20 29 3b 0d 0a 0d 0a 53 45 4c 45 43 54 tes );....SELECT
1570: 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 CREATE VIRTUAL
1580: 54 41 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 TABLE my_table U
1590: 53 49 4e 47 20 56 69 72 74 75 61 6c 44 62 66 20 SING VirtualDbf
15a0: 28 20 64 62 66 5f 70 61 74 68 20 2c 20 63 68 61 ( dbf_path , cha
15b0: 72 73 65 74 5f 65 6e 63 6f 64 69 6e 67 20 2c 20 rset_encoding ,
15c0: 74 65 78 74 5f 64 61 74 65 73 20 2c 20 63 6f 6c text_dates , col
15d0: 6e 61 6d 65 5f 63 61 73 65 20 29 3b 0d 0a 3c 2f name_case );..</
15e0: 76 65 72 62 61 74 69 6d 3e 0d 0a 53 75 70 70 6f verbatim>..Suppo
15f0: 72 74 65 64 20 61 72 67 75 6d 65 6e 74 73 20 61 rted arguments a
1600: 6e 64 20 74 68 65 69 72 20 69 6e 74 65 72 70 72 nd their interpr
1610: 65 74 61 74 69 6f 6e 3a 0d 0a 3c 75 6c 3e 0d 0a etation:..<ul>..
1620: 3c 6c 69 3e 3c 62 3e 64 62 66 5f 70 61 74 68 3c <li><b>dbf_path<
1630: 2f 62 3e 20 28 3c 69 3e 3c 62 3e 6d 61 6e 64 61 /b> (<i><b>manda
1640: 74 6f 72 79 3c 2f 62 3e 3c 2f 69 3e 29 3a 20 74 tory</b></i>): t
1650: 68 65 20 72 65 6c 61 74 69 76 65 20 6f 72 20 61 he relative or a
1660: 62 73 6f 6c 75 74 65 20 70 61 74 68 6e 61 6d 65 bsolute pathname
1670: 20 6c 65 61 64 69 6e 67 20 74 6f 20 74 68 65 20 leading to the
1680: 65 78 74 65 72 6e 61 6c 20 44 42 46 20 66 69 6c external DBF fil
1690: 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 e...<ul>..<li><b
16a0: 3e 4e 6f 74 65 3c 2f 62 3e 3a 20 74 68 65 20 66 >Note</b>: the f
16b0: 75 6c 6c 20 70 61 74 68 6e 61 6d 65 20 6d 75 73 ull pathname mus
16c0: 74 20 62 65 20 70 61 73 73 65 64 2c 20 69 6e 63 t be passed, inc
16d0: 6c 75 64 69 6e 67 20 74 68 65 20 66 69 6e 61 6c luding the final
16e0: 20 3c 69 3e 2a 2e 64 62 66 3c 2f 69 3e 20 73 75 <i>*.dbf</i> su
16f0: 66 66 69 78 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c ffix.</li>..</ul
1700: 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e 63 ></li>..<li><b>c
1710: 68 61 72 73 65 74 5f 65 6e 63 6f 64 69 6e 67 3c harset_encoding<
1720: 2f 62 3e 20 28 3c 69 3e 3c 62 3e 6d 61 6e 64 61 /b> (<i><b>manda
1730: 74 6f 72 79 3c 2f 62 3e 3c 2f 69 3e 29 3a 20 63 tory</b></i>): c
1740: 61 6e 6f 6e 69 63 61 6c 20 6e 61 6d 65 20 6f 66 anonical name of
1750: 20 74 68 65 20 63 68 61 72 73 65 74 20 65 6e 63 the charset enc
1760: 6f 64 69 6e 67 20 61 64 6f 70 74 65 64 20 62 79 oding adopted by
1770: 20 74 68 65 20 3c 62 3e 44 42 46 3c 2f 62 3e 20 the <b>DBF</b>
1780: 6d 65 6d 62 65 72 2e 0d 0a 3c 75 6c 3e 0d 0a 3c member...<ul>..<
1790: 6c 69 3e 45 78 61 6d 70 6c 65 73 20 6f 66 20 76 li>Examples of v
17a0: 61 6c 69 64 20 6e 61 6d 65 73 20 61 72 65 3a 20 alid names are:
17b0: 3c 62 3e 41 53 43 49 49 3c 2f 62 3e 2c 20 3c 62 <b>ASCII</b>, <b
17c0: 3e 55 54 46 2d 38 3c 2f 62 3e 2c 20 3c 62 3e 43 >UTF-8</b>, <b>C
17d0: 50 38 35 30 3c 2f 62 3e 2c 20 3c 62 3e 49 53 4f P850</b>, <b>ISO
17e0: 2d 38 38 34 39 2d 31 3c 2f 62 3e 3c 2f 6c 69 3e -8849-1</b></li>
17f0: 0d 0a 3c 6c 69 3e 59 6f 75 20 63 61 6e 20 63 68 ..<li>You can ch
1800: 65 63 6b 20 74 68 65 20 66 75 6c 6c 20 6c 69 73 eck the full lis
1810: 74 20 6f 66 20 73 75 70 70 6f 72 74 65 64 20 63 t of supported c
1820: 68 61 72 73 65 74 20 65 6e 63 6f 64 69 6e 67 73 harset encodings
1830: 20 66 72 6f 6d 20 3c 61 20 68 72 65 66 3d 22 68 from <a href="h
1840: 74 74 70 73 3a 2f 2f 77 77 77 2e 67 6e 75 2e 6f ttps://www.gnu.o
1850: 72 67 2f 73 6f 66 74 77 61 72 65 2f 6c 69 62 69 rg/software/libi
1860: 63 6f 6e 76 2f 22 3e 68 65 72 65 3c 2f 61 3e 2e conv/">here</a>.
1870: 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 </li>..</ul></li
1880: 3e 0d 0a 3c 6c 69 3e 3c 62 3e 74 65 78 74 5f 64 >..<li><b>text_d
1890: 61 74 65 73 3c 2f 62 3e 20 28 3c 69 3e 3c 62 3e ates</b> (<i><b>
18a0: 6f 70 74 69 6f 6e 61 6c 3c 2f 62 3e 3c 2f 69 3e optional</b></i>
18b0: 29 3a 20 74 68 69 73 20 69 73 20 61 20 3c 62 3e ): this is a <b>
18c0: 42 4f 4f 4c 45 41 4e 3c 2f 62 3e 20 66 6c 61 67 BOOLEAN</b> flag
18d0: 3a 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 69 66 20 :..<ul>..<li>if
18e0: 73 65 74 20 74 6f 20 3c 62 3e 30 3c 2f 62 3e 20 set to <b>0</b>
18f0: 28 3c 62 3e 46 41 4c 53 45 3c 2f 62 3e 29 20 61 (<b>FALSE</b>) a
1900: 6c 6c 20 66 69 65 6c 64 73 20 6f 66 20 74 68 65 ll fields of the
1910: 20 3c 62 3e 44 41 54 45 3c 2f 62 3e 20 74 79 70 <b>DATE</b> typ
1920: 65 20 77 69 6c 6c 20 62 65 20 72 65 70 72 65 73 e will be repres
1930: 65 6e 74 65 64 20 61 73 20 3c 61 20 68 72 65 66 ented as <a href
1940: 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 73 71 ="https://www.sq
1950: 6c 69 74 65 2e 6f 72 67 2f 6c 61 6e 67 5f 64 61 lite.org/lang_da
1960: 74 65 66 75 6e 63 2e 68 74 6d 6c 22 3e 6a 75 6c tefunc.html">jul
1970: 69 61 6e 20 64 61 74 65 73 3c 2f 61 3e 3c 2f 6c ian dates</a></l
1980: 69 3e 0d 0a 3c 6c 69 3e 69 66 20 73 65 74 20 74 i>..<li>if set t
1990: 6f 20 61 6e 79 20 6f 74 68 65 72 20 69 6e 74 65 o any other inte
19a0: 67 65 72 20 76 61 6c 75 65 20 28 3c 62 3e 54 52 ger value (<b>TR
19b0: 55 45 3c 2f 62 3e 29 20 61 6c 6c 20 66 69 65 6c UE</b>) all fiel
19c0: 64 73 20 6f 66 20 74 68 65 20 3c 62 3e 44 41 54 ds of the <b>DAT
19d0: 45 3c 2f 62 3e 20 74 79 70 65 20 77 69 6c 6c 20 E</b> type will
19e0: 62 65 20 72 65 70 72 65 73 65 6e 74 65 64 20 61 be represented a
19f0: 73 20 54 65 78 74 20 53 74 72 69 6e 67 73 20 61 s Text Strings a
1a00: 73 20 65 2e 67 2e 20 3c 62 3e 32 30 31 38 2d 30 s e.g. <b>2018-0
1a10: 38 2d 32 31 3c 2f 62 3e 3c 2f 6c 69 3e 0d 0a 3c 8-21</b></li>..<
1a20: 6c 69 3e 69 66 20 6e 6f 74 20 65 78 70 6c 69 63 li>if not explic
1a30: 69 74 6c 79 20 73 70 65 63 69 66 69 65 64 2c 20 itly specified,
1a40: 3c 62 3e 54 52 55 45 3c 2f 62 3e 20 77 69 6c 6c <b>TRUE</b> will
1a50: 20 61 6c 77 61 79 73 20 62 65 20 61 73 73 75 6d always be assum
1a60: 65 64 20 28 64 65 66 61 75 6c 74 20 73 65 74 74 ed (default sett
1a70: 69 6e 67 29 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c ing).</li>..</ul
1a80: 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e 63 ></li>..<li><b>c
1a90: 6f 6c 6e 61 6d 65 5f 63 61 73 65 3c 2f 62 3e 20 olname_case</b>
1aa0: 28 3c 69 3e 3c 62 3e 6f 70 74 69 6f 6e 61 6c 3c (<i><b>optional<
1ab0: 2f 62 3e 3c 2f 69 3e 29 3a 20 74 68 69 73 20 61 /b></i>): this a
1ac0: 72 67 75 6d 65 6e 74 20 73 70 65 63 69 66 69 65 rgument specifie
1ad0: 73 20 69 66 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 s if all column
1ae0: 6e 61 6d 65 73 20 73 68 6f 75 6c 64 20 62 65 20 names should be
1af0: 63 6f 6e 73 69 64 65 72 65 64 20 75 70 70 65 72 considered upper
1b00: 63 61 73 65 20 6f 72 20 6c 6f 77 65 72 63 61 73 case or lowercas
1b10: 65 2e 3c 62 72 3e 0d 0a 56 61 6c 69 64 20 73 65 e.<br>..Valid se
1b20: 74 74 69 6e 67 73 20 61 72 65 3a 0d 0a 3c 75 6c ttings are:..<ul
1b30: 3e 0d 0a 3c 6c 69 3e 3c 62 3e 75 70 70 65 72 63 >..<li><b>upperc
1b40: 61 73 65 3c 2f 62 3e 20 6f 72 20 3c 62 3e 75 70 ase</b> or <b>up
1b50: 70 65 72 3c 2f 62 3e 3a 20 61 6c 6c 20 63 6f 6c per</b>: all col
1b60: 75 6d 6e 20 6e 61 6d 65 73 20 77 69 6c 6c 20 62 umn names will b
1b70: 65 20 66 75 6c 6c 79 20 63 61 70 69 74 61 6c 69 e fully capitali
1b80: 7a 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c zed.</li>..<li><
1b90: 62 3e 6c 6f 77 65 72 63 61 73 65 3c 2f 62 3e 20 b>lowercase</b>
1ba0: 6f 72 20 3c 62 3e 6c 6f 77 65 72 3c 2f 62 3e 3a or <b>lower</b>:
1bb0: 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 all column name
1bc0: 73 20 77 69 6c 6c 20 62 65 20 66 75 6c 6c 20 6c s will be full l
1bd0: 6f 77 65 72 63 61 73 65 2e 3c 2f 6c 69 3e 0d 0a owercase.</li>..
1be0: 3c 6c 69 3e 3c 62 3e 73 61 6d 65 63 61 73 65 3c <li><b>samecase<
1bf0: 2f 62 3e 20 6f 72 20 3c 62 3e 73 61 6d 65 3c 2f /b> or <b>same</
1c00: 62 3e 3a 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e b>: all column n
1c10: 61 6d 65 73 20 77 69 6c 6c 20 62 65 20 65 78 61 ames will be exa
1c20: 63 74 6c 79 20 70 72 65 73 65 72 76 65 64 20 61 ctly preserved a
1c30: 73 20 74 68 65 79 20 61 72 65 20 64 65 66 69 6e s they are defin
1c40: 65 64 20 69 6e 74 6f 20 74 68 65 20 44 42 46 20 ed into the DBF
1c50: 6d 65 6d 65 62 65 72 2e 3c 2f 6c 69 3e 0d 0a 3c memeber.</li>..<
1c60: 6c 69 3e 69 66 20 6e 6f 74 20 73 70 65 63 69 66 li>if not specif
1c70: 69 65 64 2c 20 6f 72 20 69 66 20 61 6e 79 20 6f ied, or if any o
1c80: 74 68 65 72 20 64 65 66 69 6e 69 74 69 6f 6e 20 ther definition
1c90: 64 65 66 69 6e 69 74 69 6f 6e 20 69 73 20 66 6f definition is fo
1ca0: 75 6e 64 2c 20 3c 62 3e 6c 6f 77 65 72 63 61 73 und, <b>lowercas
1cb0: 65 3c 2f 62 3e 20 77 69 6c 6c 20 61 6c 77 61 79 e</b> will alway
1cc0: 73 20 62 65 20 61 73 73 75 6d 65 64 20 28 64 65 s be assumed (de
1cd0: 66 61 75 6c 74 20 73 65 74 74 69 6e 67 29 2e 3c fault setting).<
1ce0: 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 3e /li>..</ul></li>
1cf0: 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 74 61 ..</ul><br>..<ta
1d00: 62 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 23 66 66 ble bgcolor="#ff
1d10: 66 66 64 30 22 20 63 65 6c 6c 70 61 64 64 69 6e ffd0" cellpaddin
1d20: 67 3d 22 31 38 22 3e 3c 74 72 3e 3c 74 64 3e 0d g="18"><tr><td>.
1d30: 0a 3c 62 3e 4e 6f 74 65 3c 2f 62 3e 3a 20 71 75 .<b>Note</b>: qu
1d40: 6f 74 69 6e 67 20 6f 72 20 6e 6f 74 20 61 6e 79 oting or not any
1d50: 20 54 65 78 74 20 53 74 72 69 6e 67 20 77 68 65 Text String whe
1d60: 6e 20 69 74 20 61 70 70 65 61 72 73 20 61 73 20 n it appears as
1d70: 61 20 56 69 72 74 75 61 6c 20 54 61 62 6c 65 20 a Virtual Table
1d80: 61 72 67 75 6d 65 6e 74 20 68 61 73 20 61 62 73 argument has abs
1d90: 6f 6c 75 74 65 6c 79 20 6e 6f 20 65 66 66 65 63 olutely no effec
1da0: 74 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a t...<verbatim>..
1db0: 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 SELECT CREATE VI
1dc0: 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 RTUAL TABLE my_t
1dd0: 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 able USING Virtu
1de0: 61 6c 44 62 66 28 20 2f 68 6f 6d 65 2f 73 61 6e alDbf( /home/san
1df0: 64 72 6f 2f 6d 79 73 68 70 20 2c 20 43 50 31 32 dro/myshp , CP12
1e00: 35 32 20 2c 20 31 20 2c 20 6c 6f 77 65 72 20 29 52 , 1 , lower )
1e10: 3b 0d 0a 6f 72 0d 0a 53 45 4c 45 43 54 20 43 52 ;..or..SELECT CR
1e20: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
1e30: 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 4e LE my_table USIN
1e40: 47 20 56 69 72 74 75 61 6c 44 62 66 28 20 27 2f G VirtualDbf( '/
1e50: 68 6f 6d 65 2f 73 61 6e 64 72 6f 2f 6d 79 73 68 home/sandro/mysh
1e60: 70 27 20 2c 20 27 43 50 31 32 35 32 27 20 2c 20 p' , 'CP1252' ,
1e70: 31 20 2c 20 27 6c 6f 77 65 72 27 20 29 3b 0d 0a 1 , 'lower' );..
1e80: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 42 6f 74 </verbatim>..Bot
1e90: 68 20 6e 6f 74 61 74 69 6f 6e 73 20 77 69 6c 6c h notations will
1ea0: 20 70 72 6f 64 75 63 65 20 65 78 61 63 74 6c 79 produce exactly
1eb0: 20 74 68 65 20 73 61 6d 65 20 69 64 65 6e 74 69 the same identi
1ec0: 63 61 6c 20 72 65 73 75 6c 74 2e 0d 0a 3c 2f 74 cal result...</t
1ed0: 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 0d d></tr></table>.
1ee0: 0a 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 .<br>..<table bg
1ef0: 63 6f 6c 6f 72 3d 22 23 64 30 66 66 64 30 22 20 color="#d0ffd0"
1f00: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 31 38 22 cellpadding="18"
1f10: 3e 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 68 33 3e 42 ><tr><td>..<h3>B
1f20: 65 73 74 20 70 72 61 63 74 69 63 65 73 20 61 6e est practices an
1f30: 64 20 6b 6e 6f 77 6e 20 6c 69 6d 69 74 61 74 69 d known limitati
1f40: 6f 6e 73 3c 2f 68 33 3e 0d 0a 3c 75 6c 3e 0d 0a ons</h3>..<ul>..
1f50: 3c 6c 69 3e 56 69 72 74 75 61 6c 20 54 61 62 6c <li>Virtual Tabl
1f60: 65 73 20 61 72 65 20 6e 6f 74 20 72 65 61 6c 6c es are not reall
1f70: 79 20 67 65 6e 75 69 6e 65 20 44 61 74 61 62 61 y genuine Databa
1f80: 73 65 20 54 61 62 6c 65 73 2c 20 74 68 65 79 20 se Tables, they
1f90: 61 72 65 20 6a 75 73 74 20 70 72 65 74 65 6e 64 are just pretend
1fa0: 69 6e 67 20 74 6f 20 62 65 2e 3c 2f 6c 69 3e 0d ing to be.</li>.
1fb0: 0a 3c 6c 69 3e 56 69 72 74 75 61 6c 20 54 61 62 .<li>Virtual Tab
1fc0: 6c 65 73 20 68 61 76 65 20 76 65 72 79 20 70 6f les have very po
1fd0: 6f 72 20 73 70 65 65 64 20 70 65 72 66 6f 72 6d or speed perform
1fe0: 61 6e 63 65 73 20 77 68 65 6e 20 63 6f 6d 70 61 ances when compa
1ff0: 72 65 64 20 74 6f 20 67 65 6e 75 69 6e 65 20 44 red to genuine D
2000: 61 74 61 62 61 73 65 20 54 61 62 6c 65 73 2e 3c atabase Tables.<
2010: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 43 6f 6d 70 6c 65 /li>..<li>Comple
2020: 78 20 53 51 4c 20 71 75 65 72 69 65 73 20 3c 62 x SQL queries <b
2030: 3e 4a 4f 49 4e 3c 2f 62 3e 69 6e 67 20 73 65 76 >JOIN</b>ing sev
2040: 65 72 61 6c 20 54 61 62 6c 65 73 20 63 61 6e 20 eral Tables can
2050: 6f 66 74 65 6e 20 72 65 74 75 72 6e 20 6f 64 64 often return odd
2060: 20 61 6e 64 20 6d 69 73 6c 65 61 64 69 6e 67 20 and misleading
2070: 72 65 73 75 6c 74 73 65 74 73 2c 20 69 66 20 6f resultsets, if o
2080: 6e 65 20 6f 72 20 6d 6f 72 65 20 6f 66 20 74 68 ne or more of th
2090: 65 20 3c 62 3e 4a 4f 49 4e 3c 2f 62 3e 65 64 20 e <b>JOIN</b>ed
20a0: 54 61 62 6c 65 73 20 61 72 65 20 6f 66 20 74 68 Tables are of th
20b0: 65 20 56 69 72 74 75 61 6c 20 74 79 70 65 2e 3c e Virtual type.<
20c0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 54 68 65 20 62 65 /li>..<li>The be
20d0: 73 74 20 75 73 61 67 65 20 79 6f 75 20 63 61 6e st usage you can
20e0: 20 64 6f 20 6f 66 20 61 20 56 69 72 74 75 61 6c do of a Virtual
20f0: 20 54 61 62 6c 65 20 69 73 20 74 6f 20 6a 75 73 Table is to jus
2100: 74 20 73 75 70 70 6f 72 74 20 62 61 73 69 63 20 t support basic
2110: 64 61 74 61 20 69 6d 70 6f 72 74 20 70 72 6f 63 data import proc
2120: 65 73 73 65 73 2c 20 6f 72 20 74 6f 20 71 75 69 esses, or to qui
2130: 63 6b 6c 79 20 67 65 74 20 61 6e 20 6f 76 65 72 ckly get an over
2140: 61 6c 6c 20 67 6c 61 6e 63 65 20 61 74 20 61 20 all glance at a
2150: 66 75 6c 6c 20 64 61 74 61 73 65 74 20 77 69 74 full dataset wit
2160: 68 6f 75 74 20 6e 65 63 65 73 73 61 72 69 6c 79 hout necessarily
2170: 20 69 6d 70 6f 72 74 69 6e 67 20 69 74 20 69 6e importing it in
2180: 74 6f 20 74 68 65 20 44 61 74 61 62 61 73 65 2e to the Database.
2190: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 50 72 65 74 65 </li>..<li>Prete
21a0: 6e 64 69 6e 67 20 74 6f 20 75 73 65 20 61 20 56 nding to use a V
21b0: 69 72 74 75 61 6c 20 54 61 62 6c 65 20 61 73 20 irtual Table as
21c0: 61 20 66 75 6c 6c 20 72 65 70 6c 61 63 65 6d 65 a full replaceme
21d0: 6e 74 20 6f 66 20 69 6d 70 6f 72 74 69 6e 67 20 nt of importing
21e0: 61 6c 6c 20 64 61 74 61 20 77 69 74 68 69 6e 20 all data within
21f0: 61 20 67 65 6e 75 69 6e 65 20 44 61 74 61 62 61 a genuine Databa
2200: 73 65 20 54 61 62 6c 65 20 69 73 20 73 74 72 6f se Table is stro
2210: 6e 67 6c 79 20 64 69 73 63 6f 75 72 61 67 65 64 ngly discouraged
2220: 2c 20 61 6e 64 20 6e 65 76 65 72 20 69 73 20 61 , and never is a
2230: 20 73 6d 61 72 74 20 69 64 65 61 2e 3c 2f 6c 69 smart idea.</li
2240: 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 62 >..</ul><br>..<b
2250: 3e 57 61 72 6e 69 6e 67 3c 2f 62 3e 3a 20 56 69 >Warning</b>: Vi
2260: 72 74 75 61 6c 44 42 46 20 54 61 62 6c 65 73 20 rtualDBF Tables
2270: 61 72 65 20 61 6c 77 61 79 73 20 73 75 62 6a 65 are always subje
2280: 63 74 20 74 6f 20 3c 62 3e 52 45 41 44 2d 4f 4e ct to <b>READ-ON
2290: 4c 59 3c 2f 62 3e 20 72 65 73 74 72 69 63 74 69 LY</b> restricti
22a0: 6f 6e 73 2e 20 41 6e 79 20 61 74 74 65 6d 70 74 ons. Any attempt
22b0: 6f 20 74 6f 20 65 78 65 63 75 74 65 20 61 6e 20 o to execute an
22c0: 3c 62 3e 49 4e 53 45 52 54 3c 2f 62 3e 2c 20 3c <b>INSERT</b>, <
22d0: 62 3e 55 50 44 41 54 45 3c 2f 62 3e 20 6f 72 20 b>UPDATE</b> or
22e0: 3c 62 3e 44 45 4c 45 54 45 3c 2f 62 3e 20 73 74 <b>DELETE</b> st
22f0: 61 74 65 6d 65 6e 74 20 77 69 6c 6c 20 61 6c 77 atement will alw
2300: 61 79 73 20 72 65 74 75 72 6e 20 61 6e 20 65 72 ays return an er
2310: 72 6f 72 2e 3c 62 72 3e 0d 0a 3c 2f 74 64 3e 3c ror.<br>..</td><
2320: 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 /tr></table>..<b
2330: 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f 6c r>..<table bgcol
2340: 6f 72 3d 22 23 65 30 65 30 65 30 22 20 63 65 6c or="#e0e0e0" cel
2350: 6c 70 61 64 64 69 6e 67 3d 22 31 38 22 3e 3c 74 lpadding="18"><t
2360: 72 3e 3c 74 64 3e 0d 0a 3c 68 33 3e 52 65 6c 61 r><td>..<h3>Rela
2370: 74 65 64 20 54 6f 70 69 63 73 3c 2f 68 33 3e 0d ted Topics</h3>.
2380: 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 54 68 65 20 3c .<ul>..<li>The <
2390: 62 3e 49 6d 70 6f 72 74 44 42 46 28 29 3c 2f 62 b>ImportDBF()</b
23a0: 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 61 > SQL function a
23b0: 6c 6c 6f 77 73 20 74 6f 20 63 72 65 61 74 65 20 llows to create
23c0: 61 6e 64 20 70 6f 70 75 6c 61 74 65 20 61 20 67 and populate a g
23d0: 65 6e 75 69 6e 65 20 44 61 74 61 62 61 73 65 20 enuine Database
23e0: 54 61 62 6c 65 20 62 79 20 69 6d 70 6f 72 74 69 Table by importi
23f0: 6e 67 20 61 6e 20 65 78 74 65 72 6e 61 6c 20 44 ng an external D
2400: 42 46 20 66 69 6c 65 2e 3c 2f 6c 69 3e 0d 0a 3c BF file.</li>..<
2410: 6c 69 3e 41 6e 64 20 74 68 65 20 3c 62 3e 45 78 li>And the <b>Ex
2420: 70 6f 72 74 44 42 46 28 29 3c 2f 62 3e 20 73 69 portDBF()</b> si
2430: 73 74 65 72 20 66 75 6e 63 74 69 6f 6e 20 61 6c ster function al
2440: 6c 6f 77 73 20 74 6f 20 64 69 72 65 63 74 6c 79 lows to directly
2450: 20 65 78 70 6f 72 74 20 61 20 77 68 6f 6c 65 20 export a whole
2460: 44 61 74 61 62 61 73 65 20 54 61 62 6c 65 20 69 Database Table i
2470: 6e 74 6f 20 61 6e 20 65 78 74 65 72 6e 61 6c 20 nto an external
2480: 44 42 46 20 66 69 6c 65 2e 3c 2f 6c 69 3e 0d 0a DBF file.</li>..
2490: 3c 2f 75 6c 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 </ul>..</td></tr
24a0: 3e 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e 0d ></table>..<br>.
24b0: 0a 3c 68 72 3e 0d 0a 3c 68 31 3e 3c 61 20 69 64 .<hr>..<h1><a id
24c0: 3d 22 56 69 72 74 75 61 6c 54 65 78 74 22 3e 56 ="VirtualText">V
24d0: 69 72 74 75 61 6c 54 65 78 74 3c 2f 61 3e 3c 2f irtualText</a></
24e0: 68 31 3e 0d 0a 54 68 65 20 3c 62 3e 56 69 72 74 h1>..The <b>Virt
24f0: 75 61 6c 54 65 78 74 3c 2f 62 3e 20 49 6e 74 65 ualText</b> Inte
2500: 72 66 61 63 65 20 61 6c 6c 6f 77 73 20 74 6f 20 rface allows to
2510: 64 69 72 65 63 74 6c 79 20 61 63 63 65 73 73 20 directly access
2520: 61 6e 20 65 78 74 65 72 6e 61 6c 20 54 65 78 74 an external Text
2530: 20 66 69 6c 65 20 62 79 20 75 73 69 6e 67 20 73 file by using s
2540: 74 61 6e 64 61 72 64 20 53 70 61 74 69 61 6c 20 tandard Spatial
2550: 53 51 4c 20 71 75 65 72 69 65 73 2e 3c 62 72 3e SQL queries.<br>
2560: 0d 0a 54 68 65 20 54 65 78 74 20 46 69 6c 65 20 ..The Text File
2570: 69 73 20 65 78 70 65 63 74 65 64 20 74 6f 20 63 is expected to c
2580: 6f 6e 74 61 69 6e 20 61 20 70 72 6f 70 65 72 6c ontain a properl
2590: 79 20 66 6f 72 6d 61 74 74 65 64 20 54 61 62 6c y formatted Tabl
25a0: 65 20 61 63 63 6f 72 64 69 6e 67 6c 79 20 74 6f e accordingly to
25b0: 20 73 6f 6d 65 20 3c 62 3e 44 65 6c 69 6d 69 74 some <b>Delimit
25c0: 65 72 2d 53 65 70 61 72 61 74 65 64 2d 56 61 6c er-Separated-Val
25d0: 75 65 73 3c 2f 62 3e 20 66 6f 72 6d 61 74 20 28 ues</b> format (
25e0: 63 6f 6d 6d 61 20 73 65 70 61 72 61 74 65 64 20 comma separated
25f0: 76 61 6c 75 65 73 20 3c 69 3e 2a 2e 63 73 76 3c values <i>*.csv<
2600: 2f 69 3e 2c 20 74 61 62 20 73 65 70 61 72 61 74 /i>, tab separat
2610: 65 64 20 76 61 6c 75 65 73 20 3c 69 3e 2a 2e 74 ed values <i>*.t
2620: 78 74 3c 2f 69 3e 20 61 6e 64 20 61 6c 69 6b 65 xt</i> and alike
2630: 29 2e 3c 62 72 3e 0d 0a 53 79 6e 74 61 78 20 66 ).<br>..Syntax f
2640: 6f 72 20 63 72 65 61 74 69 6e 67 20 61 20 56 69 or creating a Vi
2650: 72 74 75 61 6c 54 65 78 74 20 54 61 62 6c 65 3a rtualText Table:
2660: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 ..<verbatim>..SE
2670: 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 52 54 LECT CREATE VIRT
2680: 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 61 62 UAL TABLE my_tab
2690: 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 61 6c le USING Virtual
26a0: 54 65 78 74 20 28 20 74 65 78 74 66 69 6c 65 5f Text ( textfile_
26b0: 70 61 74 68 20 2c 20 63 68 61 72 73 65 74 5f 65 path , charset_e
26c0: 6e 63 6f 64 69 6e 67 20 29 3b 0d 0a 0d 0a 53 45 ncoding );....SE
26d0: 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 52 54 LECT CREATE VIRT
26e0: 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 61 62 UAL TABLE my_tab
26f0: 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 61 6c le USING Virtual
2700: 54 65 78 74 20 28 20 74 65 78 74 66 69 6c 65 5f Text ( textfile_
2710: 70 61 74 68 20 2c 20 63 68 61 72 73 65 74 5f 65 path , charset_e
2720: 6e 63 6f 64 69 6e 67 20 2c 20 66 69 72 73 74 5f ncoding , first_
2730: 72 6f 77 5f 61 73 5f 74 69 74 6c 65 73 20 29 3b row_as_titles );
2740: 0d 0a 0d 0a 53 45 4c 45 43 54 20 43 52 45 41 54 ....SELECT CREAT
2750: 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 E VIRTUAL TABLE
2760: 6d 79 5f 74 61 62 6c 65 20 55 53 49 4e 47 20 56 my_table USING V
2770: 69 72 74 75 61 6c 54 65 78 74 20 28 20 74 65 78 irtualText ( tex
2780: 74 66 69 6c 65 5f 70 61 74 68 20 2c 20 63 68 61 tfile_path , cha
2790: 72 73 65 74 5f 65 6e 63 6f 64 69 6e 67 20 2c 20 rset_encoding ,
27a0: 66 69 72 73 74 5f 72 6f 77 5f 61 73 5f 74 69 74 first_row_as_tit
27b0: 6c 65 73 20 2c 20 64 65 63 69 6d 61 6c 5f 73 65 les , decimal_se
27c0: 70 61 72 61 74 6f 72 20 29 3b 0d 0a 0d 0a 53 45 parator );....SE
27d0: 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 52 54 LECT CREATE VIRT
27e0: 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 61 62 UAL TABLE my_tab
27f0: 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 61 6c le USING Virtual
2800: 54 65 78 74 20 28 20 74 65 78 74 66 69 6c 65 5f Text ( textfile_
2810: 70 61 74 68 20 2c 20 63 68 61 72 73 65 74 5f 65 path , charset_e
2820: 6e 63 6f 64 69 6e 67 20 2c 20 66 69 72 73 74 5f ncoding , first_
2830: 72 6f 77 5f 61 73 5f 74 69 74 6c 65 73 20 2c 20 row_as_titles ,
2840: 64 65 63 69 6d 61 6c 5f 73 65 70 61 72 61 74 6f decimal_separato
2850: 72 20 2c 20 74 65 78 74 5f 73 65 70 61 72 61 74 r , text_separat
2860: 6f 72 20 29 3b 0d 0a 0d 0a 53 45 4c 45 43 54 20 or );....SELECT
2870: 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 CREATE VIRTUAL T
2880: 41 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 ABLE my_table US
2890: 49 4e 47 20 56 69 72 74 75 61 6c 54 65 78 74 20 ING VirtualText
28a0: 28 20 74 65 78 74 66 69 6c 65 5f 70 61 74 68 20 ( textfile_path
28b0: 2c 20 63 68 61 72 73 65 74 5f 65 6e 63 6f 64 69 , charset_encodi
28c0: 6e 67 20 2c 20 66 69 72 73 74 5f 72 6f 77 5f 61 ng , first_row_a
28d0: 73 5f 74 69 74 6c 65 73 20 2c 20 64 65 63 69 6d s_titles , decim
28e0: 61 6c 5f 73 65 70 61 72 61 74 6f 72 20 2c 20 74 al_separator , t
28f0: 65 78 74 5f 73 65 70 61 72 61 74 6f 72 20 2c 20 ext_separator ,
2900: 66 69 65 6c 64 5f 73 65 70 61 72 61 74 6f 72 20 field_separator
2910: 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d );..</verbatim>.
2920: 0a 53 75 70 70 6f 72 74 65 64 20 61 72 67 75 6d .Supported argum
2930: 65 6e 74 73 20 61 6e 64 20 74 68 65 69 72 20 69 ents and their i
2940: 6e 74 65 72 70 72 65 74 61 74 69 6f 6e 3a 0d 0a nterpretation:..
2950: 3c 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 74 65 78 <ul>..<li><b>tex
2960: 74 66 69 6c 65 5f 70 61 74 68 3c 2f 62 3e 20 28 tfile_path</b> (
2970: 3c 69 3e 3c 62 3e 6d 61 6e 64 61 74 6f 72 79 3c <i><b>mandatory<
2980: 2f 62 3e 3c 2f 69 3e 29 3a 20 74 68 65 20 72 65 /b></i>): the re
2990: 6c 61 74 69 76 65 20 6f 72 20 61 62 73 6f 6c 75 lative or absolu
29a0: 74 65 20 70 61 74 68 6e 61 6d 65 20 6c 65 61 64 te pathname lead
29b0: 69 6e 67 20 74 6f 20 74 68 65 20 65 78 74 65 72 ing to the exter
29c0: 6e 61 6c 20 54 65 78 74 20 66 69 6c 65 2e 0d 0a nal Text file...
29d0: 3c 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 4e 6f 74 <ul>..<li><b>Not
29e0: 65 3c 2f 62 3e 3a 20 74 68 65 20 66 75 6c 6c 20 e</b>: the full
29f0: 70 61 74 68 6e 61 6d 65 20 6d 75 73 74 20 62 65 pathname must be
2a00: 20 70 61 73 73 65 64 2c 20 69 6e 63 6c 75 64 69 passed, includi
2a10: 6e 67 20 61 6e 20 65 76 65 6e 74 75 61 6c 20 66 ng an eventual f
2a20: 69 6e 61 6c 20 73 75 66 66 69 78 20 28 3c 69 3e inal suffix (<i>
2a30: 2a 2e 74 78 74 3c 2f 69 3e 2c 20 3c 69 3e 2a 2e *.txt</i>, <i>*.
2a40: 63 73 76 3c 2f 69 3e 20 61 6e 64 20 61 6c 69 6b csv</i> and alik
2a50: 65 29 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c e).</li>..</ul><
2a60: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e 63 68 61 /li>..<li><b>cha
2a70: 72 73 65 74 5f 65 6e 63 6f 64 69 6e 67 3c 2f 62 rset_encoding</b
2a80: 3e 20 28 3c 69 3e 3c 62 3e 6d 61 6e 64 61 74 6f > (<i><b>mandato
2a90: 72 79 3c 2f 62 3e 3c 2f 69 3e 29 3a 20 63 61 6e ry</b></i>): can
2aa0: 6f 6e 69 63 61 6c 20 6e 61 6d 65 20 6f 66 20 74 onical name of t
2ab0: 68 65 20 63 68 61 72 73 65 74 20 65 6e 63 6f 64 he charset encod
2ac0: 69 6e 67 20 61 64 6f 70 74 65 64 20 62 79 20 74 ing adopted by t
2ad0: 68 65 20 54 65 78 74 20 66 69 6c 65 2e 0d 0a 3c he Text file...<
2ae0: 75 6c 3e 0d 0a 3c 6c 69 3e 45 78 61 6d 70 6c 65 ul>..<li>Example
2af0: 73 20 6f 66 20 76 61 6c 69 64 20 6e 61 6d 65 73 s of valid names
2b00: 20 61 72 65 3a 20 3c 62 3e 41 53 43 49 49 3c 2f are: <b>ASCII</
2b10: 62 3e 2c 20 3c 62 3e 55 54 46 2d 38 3c 2f 62 3e b>, <b>UTF-8</b>
2b20: 2c 20 3c 62 3e 43 50 38 35 30 3c 2f 62 3e 2c 20 , <b>CP850</b>,
2b30: 3c 62 3e 49 53 4f 2d 38 38 34 39 2d 31 3c 2f 62 <b>ISO-8849-1</b
2b40: 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 59 6f 75 20 ></li>..<li>You
2b50: 63 61 6e 20 63 68 65 63 6b 20 74 68 65 20 66 75 can check the fu
2b60: 6c 6c 20 6c 69 73 74 20 6f 66 20 73 75 70 70 6f ll list of suppo
2b70: 72 74 65 64 20 63 68 61 72 73 65 74 20 65 6e 63 rted charset enc
2b80: 6f 64 69 6e 67 73 20 66 72 6f 6d 20 3c 61 20 68 odings from <a h
2b90: 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 ref="https://www
2ba0: 2e 67 6e 75 2e 6f 72 67 2f 73 6f 66 74 77 61 72 .gnu.org/softwar
2bb0: 65 2f 6c 69 62 69 63 6f 6e 76 2f 22 3e 68 65 72 e/libiconv/">her
2bc0: 65 3c 2f 61 3e 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 e</a>.</li>..</u
2bd0: 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e l></li>..<li><b>
2be0: 66 69 72 73 74 5f 72 6f 77 5f 61 73 5f 74 69 74 first_row_as_tit
2bf0: 6c 65 73 3c 2f 62 3e 20 28 3c 69 3e 3c 62 3e 6f les</b> (<i><b>o
2c00: 70 74 69 6f 6e 61 6c 3c 2f 62 3e 3c 2f 69 3e 29 ptional</b></i>)
2c10: 3a 20 74 68 69 73 20 69 73 20 61 20 3c 62 3e 42 : this is a <b>B
2c20: 4f 4f 4c 45 41 4e 3c 2f 62 3e 20 66 6c 61 67 3a OOLEAN</b> flag:
2c30: 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 69 66 20 73 ..<ul>..<li>if s
2c40: 65 74 20 74 6f 20 3c 62 3e 30 3c 2f 62 3e 20 28 et to <b>0</b> (
2c50: 3c 62 3e 46 41 4c 53 45 3c 2f 62 3e 29 20 61 6c <b>FALSE</b>) al
2c60: 6c 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 73 20 77 l column names w
2c70: 69 6c 6c 20 62 65 20 61 75 74 6f 6d 61 74 69 63 ill be automatic
2c80: 61 6c 6c 79 20 73 65 74 20 62 79 20 75 73 69 6e ally set by usin
2c90: 67 20 61 20 70 72 6f 67 72 65 73 73 69 76 65 20 g a progressive
2ca0: 73 65 71 75 65 6e 63 65 2e 3c 2f 6c 69 3e 0d 0a sequence.</li>..
2cb0: 3c 6c 69 3e 69 66 20 73 65 74 20 74 6f 20 61 6e <li>if set to an
2cc0: 79 20 6f 74 68 65 72 20 69 6e 74 65 67 65 72 20 y other integer
2cd0: 76 61 6c 75 65 20 28 3c 62 3e 54 52 55 45 3c 2f value (<b>TRUE</
2ce0: 62 3e 29 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e b>) all column n
2cf0: 61 6d 65 73 20 77 69 6c 6c 20 62 79 20 65 78 70 ames will by exp
2d00: 65 63 74 65 64 20 74 6f 20 62 65 20 64 65 66 69 ected to be defi
2d10: 6e 65 64 20 69 6e 20 74 68 65 20 76 65 72 79 20 ned in the very
2d20: 66 69 72 73 74 20 72 6f 77 20 6f 66 20 74 68 65 first row of the
2d30: 20 54 65 78 74 20 66 69 6c 65 2e 3c 2f 6c 69 3e Text file.</li>
2d40: 0d 0a 3c 6c 69 3e 69 66 20 6e 6f 74 20 65 78 70 ..<li>if not exp
2d50: 6c 69 63 69 74 6c 79 20 73 70 65 63 69 66 69 65 licitly specifie
2d60: 64 2c 20 3c 62 3e 54 52 55 45 3c 2f 62 3e 20 77 d, <b>TRUE</b> w
2d70: 69 6c 6c 20 61 6c 77 61 79 73 20 62 65 20 61 73 ill always be as
2d80: 73 75 6d 65 64 20 28 64 65 66 61 75 6c 74 20 73 sumed (default s
2d90: 65 74 74 69 6e 67 29 2e 3c 2f 6c 69 3e 0d 0a 3c etting).</li>..<
2da0: 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 75 6c 3e 0d /ul></li>..<ul>.
2db0: 0a 3c 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 .</ul></li>..<li
2dc0: 3e 3c 62 3e 64 65 63 69 6d 61 6c 5f 73 65 70 61 ><b>decimal_sepa
2dd0: 72 61 74 6f 72 3c 2f 62 3e 20 28 3c 69 3e 3c 62 rator</b> (<i><b
2de0: 3e 6f 70 74 69 6f 6e 61 6c 3c 2f 62 3e 3c 2f 69 >optional</b></i
2df0: 3e 29 3a 20 74 68 65 20 63 68 61 72 61 63 74 65 >): the characte
2e00: 72 20 61 63 74 69 6e 67 20 61 73 20 61 20 73 65 r acting as a se
2e10: 70 61 72 61 74 6f 72 20 62 65 74 77 65 65 6e 20 parator between
2e20: 74 68 65 20 69 6e 74 65 67 65 72 20 61 6e 64 20 the integer and
2e30: 64 65 63 69 6d 61 6c 20 70 61 72 74 73 20 6f 66 decimal parts of
2e40: 20 61 20 6e 75 6d 62 65 72 2e 3c 62 72 3e 0d 0a a number.<br>..
2e50: 56 61 6c 69 64 20 76 61 6c 75 65 73 20 61 72 65 Valid values are
2e60: 20 61 6e 79 20 70 72 69 6e 74 61 62 6c 65 20 63 any printable c
2e70: 68 61 72 61 63 74 65 72 20 6f 72 20 74 68 65 20 haracter or the
2e80: 73 70 65 63 69 61 6c 20 6d 6e 65 6d 6f 6e 69 63 special mnemonic
2e90: 20 6e 6f 74 61 74 69 6f 6e 73 20 3c 62 3e 50 4f notations <b>PO
2ea0: 49 4e 54 3c 2f 62 3e 20 6f 72 20 3c 62 3e 43 4f INT</b> or <b>CO
2eb0: 4d 4d 41 3c 2f 62 3e 2e 3c 62 72 3e 0d 0a 49 66 MMA</b>.<br>..If
2ec0: 20 6e 6f 74 20 65 78 70 6c 69 63 69 74 6c 79 20 not explicitly
2ed0: 73 70 65 63 69 66 69 65 64 20 3c 62 3e 50 4f 49 specified <b>POI
2ee0: 4e 54 3c 2f 62 3e 20 77 69 6c 6c 20 61 6c 77 61 NT</b> will alwa
2ef0: 79 73 20 62 65 20 61 73 73 75 6d 65 64 20 28 64 ys be assumed (d
2f00: 65 66 61 75 6c 74 20 73 65 74 74 69 6e 67 29 3c efault setting)<
2f10: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e 74 65 78 /li>..<li><b>tex
2f20: 74 5f 73 65 70 61 72 61 74 6f 72 3c 2f 62 3e 20 t_separator</b>
2f30: 28 3c 69 3e 3c 62 3e 6f 70 74 69 6f 6e 61 6c 3c (<i><b>optional<
2f40: 2f 62 3e 3c 2f 69 3e 29 3a 20 74 68 65 20 63 68 /b></i>): the ch
2f50: 61 72 61 63 74 65 72 20 61 63 74 69 6e 67 20 61 aracter acting a
2f60: 73 20 61 20 73 74 72 69 6e 67 20 64 65 6c 69 6d s a string delim
2f70: 69 74 65 72 2e 3c 62 72 3e 0d 0a 56 61 6c 69 64 iter.<br>..Valid
2f80: 20 76 61 6c 75 65 73 20 61 72 65 20 61 6e 79 20 values are any
2f90: 70 72 69 6e 74 61 62 6c 65 20 63 68 61 72 61 63 printable charac
2fa0: 74 65 72 20 6f 72 20 74 68 65 20 73 70 65 63 69 ter or the speci
2fb0: 61 6c 20 6d 6e 65 6d 6f 6e 69 63 20 6e 6f 74 61 al mnemonic nota
2fc0: 74 69 6f 6e 73 20 3c 62 3e 53 49 4e 47 4c 45 51 tions <b>SINGLEQ
2fd0: 55 4f 54 45 3c 2f 62 3e 2c 20 3c 62 3e 44 4f 55 UOTE</b>, <b>DOU
2fe0: 42 4c 45 51 55 4f 54 45 3c 2f 62 3e 20 6f 72 20 BLEQUOTE</b> or
2ff0: 3c 62 3e 4e 4f 4e 45 3c 2f 62 3e 2e 3c 62 72 3e <b>NONE</b>.<br>
3000: 0d 0a 49 66 20 6e 6f 74 20 65 78 70 6c 69 63 69 ..If not explici
3010: 74 6c 79 20 73 70 65 63 69 66 69 65 64 20 3c 62 tly specified <b
3020: 3e 44 4f 55 42 4c 45 51 55 4f 54 45 3c 2f 62 3e >DOUBLEQUOTE</b>
3030: 20 77 69 6c 6c 20 61 6c 77 61 79 73 20 62 65 20 will always be
3040: 61 73 73 75 6d 65 64 20 28 64 65 66 61 75 6c 74 assumed (default
3050: 20 73 65 74 74 69 6e 67 29 3c 2f 6c 69 3e 0d 0a setting)</li>..
3060: 3c 6c 69 3e 3c 62 3e 66 69 65 6c 64 5f 73 65 70 <li><b>field_sep
3070: 61 72 61 74 6f 72 3c 2f 62 3e 20 28 3c 69 3e 3c arator</b> (<i><
3080: 62 3e 6f 70 74 69 6f 6e 61 6c 3c 2f 62 3e 3c 2f b>optional</b></
3090: 69 3e 29 3a 20 74 68 65 20 63 68 61 72 61 63 74 i>): the charact
30a0: 65 72 20 61 63 74 69 6e 67 20 61 73 20 61 20 64 er acting as a d
30b0: 65 6c 69 6d 69 74 65 72 20 62 65 74 77 65 65 6e elimiter between
30c0: 20 63 6f 6e 73 65 63 75 74 69 76 65 20 66 69 65 consecutive fie
30d0: 6c 64 73 2e 3c 62 72 3e 0d 0a 56 61 6c 69 64 20 lds.<br>..Valid
30e0: 76 61 6c 75 65 73 20 61 72 65 20 61 6e 79 20 70 values are any p
30f0: 72 69 6e 74 61 62 6c 65 20 63 68 61 72 61 63 74 rintable charact
3100: 65 72 20 6f 72 20 74 68 65 20 73 70 65 63 69 61 er or the specia
3110: 6c 20 6d 6e 65 6d 6f 6e 69 63 20 6e 6f 74 61 74 l mnemonic notat
3120: 69 6f 6e 73 20 3c 62 3e 54 41 42 3c 2f 62 3e 2e ions <b>TAB</b>.
3130: 3c 62 72 3e 0d 0a 49 66 20 6e 6f 74 20 65 78 70 <br>..If not exp
3140: 6c 69 63 69 74 6c 79 20 73 70 65 63 69 66 69 65 licitly specifie
3150: 64 20 3c 62 3e 54 41 42 3c 2f 62 3e 20 77 69 6c d <b>TAB</b> wil
3160: 6c 20 61 6c 77 61 79 73 20 62 65 20 61 73 73 75 l always be assu
3170: 6d 65 64 20 28 64 65 66 61 75 6c 74 20 73 65 74 med (default set
3180: 74 69 6e 67 29 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c ting)</li>..</ul
3190: 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 ><br>..<table bg
31a0: 63 6f 6c 6f 72 3d 22 23 66 66 66 66 64 30 22 20 color="#ffffd0"
31b0: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 31 38 22 cellpadding="18"
31c0: 3e 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 4e 6f ><tr><td>..<b>No
31d0: 74 65 3c 2f 62 3e 3a 20 71 75 6f 74 69 6e 67 20 te</b>: quoting
31e0: 6f 72 20 6e 6f 74 20 61 6e 79 20 54 65 78 74 20 or not any Text
31f0: 53 74 72 69 6e 67 20 77 68 65 6e 20 69 74 20 61 String when it a
3200: 70 70 65 61 72 73 20 61 73 20 61 20 56 69 72 74 ppears as a Virt
3210: 75 61 6c 20 54 61 62 6c 65 20 61 72 67 75 6d 65 ual Table argume
3220: 6e 74 20 68 61 73 20 61 62 73 6f 6c 75 74 65 6c nt has absolutel
3230: 79 20 6e 6f 20 65 66 66 65 63 74 2e 0d 0a 3c 76 y no effect...<v
3240: 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 erbatim>..SELECT
3250: 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 CREATE VIRTUAL
3260: 54 41 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 TABLE my_table U
3270: 53 49 4e 47 20 56 69 72 74 75 61 6c 54 65 78 74 SING VirtualText
3280: 28 20 2f 68 6f 6d 65 2f 73 61 6e 64 72 6f 2f 6d ( /home/sandro/m
3290: 79 66 69 6c 65 2e 74 78 74 20 2c 20 43 50 31 32 yfile.txt , CP12
32a0: 35 32 20 2c 20 31 20 2c 20 50 4f 49 4e 54 20 2c 52 , 1 , POINT ,
32b0: 20 4e 4f 4e 45 20 2c 20 54 41 42 20 29 3b 0d 0a NONE , TAB );..
32c0: 6f 72 0d 0a 53 45 4c 45 43 54 20 43 52 45 41 54 or..SELECT CREAT
32d0: 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 E VIRTUAL TABLE
32e0: 6d 79 5f 74 61 62 6c 65 20 55 53 49 4e 47 20 56 my_table USING V
32f0: 69 72 74 75 61 6c 54 65 78 74 28 20 27 2f 68 6f irtualText( '/ho
3300: 6d 65 2f 73 61 6e 64 72 6f 2f 6d 79 66 69 6c 65 me/sandro/myfile
3310: 2e 74 78 74 27 20 2c 20 27 43 50 31 32 35 32 27 .txt' , 'CP1252'
3320: 20 2c 20 31 20 2c 20 27 50 4f 49 4e 54 27 20 2c , 1 , 'POINT' ,
3330: 20 27 4e 4f 4e 45 27 20 2c 20 27 54 41 42 27 20 'NONE' , 'TAB'
3340: 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d );..</verbatim>.
3350: 0a 42 6f 74 68 20 6e 6f 74 61 74 69 6f 6e 73 20 .Both notations
3360: 77 69 6c 6c 20 70 72 6f 64 75 63 65 20 65 78 61 will produce exa
3370: 63 74 6c 79 20 74 68 65 20 73 61 6d 65 20 69 64 ctly the same id
3380: 65 6e 74 69 63 61 6c 20 72 65 73 75 6c 74 2e 0d entical result..
3390: 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 .</td></tr></tab
33a0: 6c 65 3e 0d 0a 3c 62 72 3e 0d 0a 3c 74 61 62 6c le>..<br>..<tabl
33b0: 65 20 62 67 63 6f 6c 6f 72 3d 22 23 64 30 66 66 e bgcolor="#d0ff
33c0: 64 30 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d d0" cellpadding=
33d0: 22 31 38 22 3e 3c 74 72 3e 3c 74 64 3e 0d 0a 3c "18"><tr><td>..<
33e0: 68 33 3e 42 65 73 74 20 70 72 61 63 74 69 63 65 h3>Best practice
33f0: 73 20 61 6e 64 20 6b 6e 6f 77 6e 20 6c 69 6d 69 s and known limi
3400: 74 61 74 69 6f 6e 73 3c 2f 68 33 3e 0d 0a 3c 75 tations</h3>..<u
3410: 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 42 65 20 61 77 l>..<li><b>Be aw
3420: 61 72 65 3c 2f 62 3e 3a 20 6f 70 65 6e 69 6e 67 are</b>: opening
3430: 20 62 69 67 20 6f 72 20 68 75 67 65 20 74 65 78 big or huge tex
3440: 74 20 66 69 6c 65 73 20 63 6f 75 6c 64 20 65 61 t files could ea
3450: 73 69 6c 79 20 72 65 71 75 69 72 65 20 6d 61 73 sily require mas
3460: 73 69 76 65 20 52 41 4d 20 61 6c 6c 6f 63 61 74 sive RAM allocat
3470: 69 6f 6e 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e ions.</li>..<li>
3480: 3c 62 3e 57 61 72 6e 69 6e 67 3c 2f 62 3e 3a 20 <b>Warning</b>:
3490: 61 74 74 65 6d 70 74 69 6e 67 20 74 6f 20 61 63 attempting to ac
34a0: 63 65 73 73 20 61 6e 20 65 78 74 65 72 6e 61 6c cess an external
34b0: 20 54 65 78 74 20 66 69 6c 65 20 62 79 20 62 6c Text file by bl
34c0: 69 6e 64 6c 79 20 73 70 65 63 69 66 79 69 6e 67 indly specifying
34d0: 20 72 61 6e 64 6f 6d 6c 79 20 63 68 6f 6f 73 65 randomly choose
34e0: 6e 20 64 65 6c 69 6d 69 74 65 72 73 20 6f 72 20 n delimiters or
34f0: 73 65 70 61 72 61 74 6f 72 73 20 6d 61 79 20 65 separators may e
3500: 61 73 69 6c 79 20 68 61 76 65 20 63 61 74 61 73 asily have catas
3510: 74 72 6f 70 68 69 63 20 65 66 66 65 63 74 73 2e trophic effects.
3520: 3c 62 72 3e 0d 0a 41 6c 77 61 79 73 20 63 61 72 <br>..Always car
3530: 65 66 75 6c 6c 79 20 63 68 65 63 6b 20 74 68 65 efully check the
3540: 20 61 63 74 75 61 6c 20 70 61 79 6c 6f 61 64 20 actual payload
3550: 6f 66 20 74 68 65 20 54 65 78 74 20 66 69 6c 65 of the Text file
3560: 20 62 65 66 6f 72 65 20 61 74 74 65 6d 70 74 69 before attempti
3570: 6e 67 20 74 6f 20 61 63 63 65 73 73 20 69 74 2e ng to access it.
3580: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 56 69 72 74 75 </li>..<li>Virtu
3590: 61 6c 20 54 61 62 6c 65 73 20 61 72 65 20 6e 6f al Tables are no
35a0: 74 20 72 65 61 6c 6c 79 20 67 65 6e 75 69 6e 65 t really genuine
35b0: 20 44 61 74 61 62 61 73 65 20 54 61 62 6c 65 73 Database Tables
35c0: 2c 20 74 68 65 79 20 61 72 65 20 6a 75 73 74 20 , they are just
35d0: 70 72 65 74 65 6e 64 69 6e 67 20 74 6f 20 62 65 pretending to be
35e0: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 56 69 72 74 .</li>..<li>Virt
35f0: 75 61 6c 20 54 61 62 6c 65 73 20 68 61 76 65 20 ual Tables have
3600: 76 65 72 79 20 70 6f 6f 72 20 73 70 65 65 64 20 very poor speed
3610: 70 65 72 66 6f 72 6d 61 6e 63 65 73 20 77 68 65 performances whe
3620: 6e 20 63 6f 6d 70 61 72 65 64 20 74 6f 20 67 65 n compared to ge
3630: 6e 75 69 6e 65 20 44 61 74 61 62 61 73 65 20 54 nuine Database T
3640: 61 62 6c 65 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 ables.</li>..<li
3650: 3e 43 6f 6d 70 6c 65 78 20 53 51 4c 20 71 75 65 >Complex SQL que
3660: 72 69 65 73 20 3c 62 3e 4a 4f 49 4e 3c 2f 62 3e ries <b>JOIN</b>
3670: 69 6e 67 20 73 65 76 65 72 61 6c 20 54 61 62 6c ing several Tabl
3680: 65 73 20 63 61 6e 20 6f 66 74 65 6e 20 72 65 74 es can often ret
3690: 75 72 6e 20 6f 64 64 20 61 6e 64 20 6d 69 73 6c urn odd and misl
36a0: 65 61 64 69 6e 67 20 72 65 73 75 6c 74 73 65 74 eading resultset
36b0: 73 2c 20 69 66 20 6f 6e 65 20 6f 72 20 6d 6f 72 s, if one or mor
36c0: 65 20 6f 66 20 74 68 65 20 3c 62 3e 4a 4f 49 4e e of the <b>JOIN
36d0: 3c 2f 62 3e 65 64 20 54 61 62 6c 65 73 20 61 72 </b>ed Tables ar
36e0: 65 20 6f 66 20 74 68 65 20 56 69 72 74 75 61 6c e of the Virtual
36f0: 20 74 79 70 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 type.</li>..<li
3700: 3e 54 68 65 20 62 65 73 74 20 75 73 61 67 65 20 >The best usage
3710: 79 6f 75 20 63 61 6e 20 64 6f 20 6f 66 20 61 20 you can do of a
3720: 56 69 72 74 75 61 6c 20 54 61 62 6c 65 20 69 73 Virtual Table is
3730: 20 74 6f 20 6a 75 73 74 20 73 75 70 70 6f 72 74 to just support
3740: 20 62 61 73 69 63 20 64 61 74 61 20 69 6d 70 6f basic data impo
3750: 72 74 20 70 72 6f 63 65 73 73 65 73 2c 20 6f 72 rt processes, or
3760: 20 74 6f 20 71 75 69 63 6b 6c 79 20 67 65 74 20 to quickly get
3770: 61 6e 20 6f 76 65 72 61 6c 6c 20 67 6c 61 6e 63 an overall glanc
3780: 65 20 61 74 20 61 20 66 75 6c 6c 20 64 61 74 61 e at a full data
3790: 73 65 74 20 77 69 74 68 6f 75 74 20 6e 65 63 65 set without nece
37a0: 73 73 61 72 69 6c 79 20 69 6d 70 6f 72 74 69 6e ssarily importin
37b0: 67 20 69 74 20 69 6e 74 6f 20 74 68 65 20 44 61 g it into the Da
37c0: 74 61 62 61 73 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c tabase.</li>..<l
37d0: 69 3e 50 72 65 74 65 6e 64 69 6e 67 20 74 6f 20 i>Pretending to
37e0: 75 73 65 20 61 20 56 69 72 74 75 61 6c 20 54 61 use a Virtual Ta
37f0: 62 6c 65 20 61 73 20 61 20 66 75 6c 6c 20 72 65 ble as a full re
3800: 70 6c 61 63 65 6d 65 6e 74 20 6f 66 20 69 6d 70 placement of imp
3810: 6f 72 74 69 6e 67 20 61 6c 6c 20 64 61 74 61 20 orting all data
3820: 77 69 74 68 69 6e 20 61 20 67 65 6e 75 69 6e 65 within a genuine
3830: 20 44 61 74 61 62 61 73 65 20 54 61 62 6c 65 20 Database Table
3840: 69 73 20 73 74 72 6f 6e 67 6c 79 20 64 69 73 63 is strongly disc
3850: 6f 75 72 61 67 65 64 2c 20 61 6e 64 20 6e 65 76 ouraged, and nev
3860: 65 72 20 69 73 20 61 20 73 6d 61 72 74 20 69 64 er is a smart id
3870: 65 61 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c ea.</li>..</ul><
3880: 62 72 3e 0d 0a 3c 62 3e 57 61 72 6e 69 6e 67 3c br>..<b>Warning<
3890: 2f 62 3e 3a 20 56 69 72 74 75 61 6c 54 65 78 74 /b>: VirtualText
38a0: 20 54 61 62 6c 65 73 20 61 72 65 20 61 6c 77 61 Tables are alwa
38b0: 79 73 20 73 75 62 6a 65 63 74 20 74 6f 20 3c 62 ys subject to <b
38c0: 3e 52 45 41 44 2d 4f 4e 4c 59 3c 2f 62 3e 20 72 >READ-ONLY</b> r
38d0: 65 73 74 72 69 63 74 69 6f 6e 73 2e 20 41 6e 79 estrictions. Any
38e0: 20 61 74 74 65 6d 70 74 6f 20 74 6f 20 65 78 65 attempto to exe
38f0: 63 75 74 65 20 61 6e 20 3c 62 3e 49 4e 53 45 52 cute an <b>INSER
3900: 54 3c 2f 62 3e 2c 20 3c 62 3e 55 50 44 41 54 45 T</b>, <b>UPDATE
3910: 3c 2f 62 3e 20 6f 72 20 3c 62 3e 44 45 4c 45 54 </b> or <b>DELET
3920: 45 3c 2f 62 3e 20 73 74 61 74 65 6d 65 6e 74 20 E</b> statement
3930: 77 69 6c 6c 20 61 6c 77 61 79 73 20 72 65 74 75 will always retu
3940: 72 6e 20 61 6e 20 65 72 72 6f 72 2e 3c 62 72 3e rn an error.<br>
3950: 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 ..</td></tr></ta
3960: 62 6c 65 3e 0d 0a 3c 62 72 3e 0d 0a 3c 68 72 3e ble>..<br>..<hr>
3970: 0d 0a 3c 68 31 3e 3c 61 20 69 64 3d 22 56 69 72 ..<h1><a id="Vir
3980: 74 75 61 6c 46 44 4f 22 3e 56 69 72 74 75 61 6c tualFDO">Virtual
3990: 46 44 4f 3c 2f 61 3e 3c 2f 68 31 3e 0d 0a 54 68 FDO</a></h1>..Th
39a0: 65 20 3c 62 3e 56 69 72 74 75 61 6c 46 44 4f 3c e <b>VirtualFDO<
39b0: 2f 62 3e 20 49 6e 74 65 72 66 61 63 65 20 61 6c /b> Interface al
39c0: 6c 6f 77 73 20 74 6f 20 64 69 72 65 63 74 6c 79 lows to directly
39d0: 20 61 63 63 65 73 73 20 61 20 53 70 61 74 69 61 access a Spatia
39e0: 6c 20 54 61 62 6c 65 20 63 6f 6e 74 61 69 6e 69 l Table containi
39f0: 6e 67 20 3c 62 3e 46 44 4f 20 62 69 6e 61 72 79 ng <b>FDO binary
3a00: 20 47 65 6f 6d 65 74 72 69 65 73 3c 2f 62 3e 20 Geometries</b>
3a10: 65 78 61 63 74 6c 79 20 61 73 20 69 66 20 77 61 exactly as if wa
3a20: 73 20 61 20 53 70 61 74 69 61 4c 69 74 65 27 73 s a SpatiaLite's
3a30: 20 6f 77 6e 20 6e 61 74 69 76 65 20 54 61 62 6c own native Tabl
3a40: 65 2e 3c 62 72 3e 0d 0a 46 44 4f 20 69 73 20 61 e.<br>..FDO is a
3a50: 6e 20 61 6c 74 65 72 6e 61 74 69 76 65 20 62 69 n alternative bi
3a60: 6e 61 72 79 20 66 6f 72 6d 61 74 20 66 6f 72 20 nary format for
3a70: 47 65 6f 6d 65 74 72 69 65 73 20 73 74 6f 72 65 Geometries store
3a80: 64 20 77 69 74 68 69 6e 20 61 20 53 51 4c 69 74 d within a SQLit
3a90: 65 20 44 61 74 61 62 61 73 65 3b 20 79 6f 75 20 e Database; you
3aa0: 63 61 6e 20 65 76 65 6e 74 75 61 6c 6c 79 20 72 can eventually r
3ab0: 65 61 64 20 74 68 65 20 3c 61 20 68 72 65 66 3d ead the <a href=
3ac0: 22 68 74 74 70 73 3a 2f 2f 74 72 61 63 2e 6f 73 "https://trac.os
3ad0: 67 65 6f 2e 6f 72 67 2f 66 64 6f 2f 77 69 6b 69 geo.org/fdo/wiki
3ae0: 2f 46 44 4f 52 66 63 31 36 22 3e 52 46 43 20 31 /FDORfc16">RFC 1
3af0: 36 3c 2f 61 3e 20 73 70 65 63 69 66 69 63 61 74 6</a> specificat
3b00: 69 6f 6e 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 ion for more det
3b10: 61 69 6c 73 2e 3c 62 72 3e 0d 0a 53 79 6e 74 61 ails.<br>..Synta
3b20: 78 20 66 6f 72 20 63 72 65 61 74 69 6e 67 20 61 x for creating a
3b30: 20 56 69 72 74 75 61 6c 46 44 4f 20 54 61 62 6c VirtualFDO Tabl
3b40: 65 3a 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a e:..<verbatim>..
3b50: 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 SELECT CREATE VI
3b60: 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 RTUAL TABLE my_t
3b70: 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 able USING Virtu
3b80: 61 6c 46 64 6f 20 28 20 74 61 62 6c 65 5f 6e 61 alFdo ( table_na
3b90: 6d 65 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 me );..</verbati
3ba0: 6d 3e 0d 0a 53 75 70 70 6f 72 74 65 64 20 61 72 m>..Supported ar
3bb0: 67 75 6d 65 6e 74 20 61 6e 64 20 69 74 73 20 69 gument and its i
3bc0: 6e 74 65 72 70 72 65 74 61 74 69 6f 6e 3a 0d 0a nterpretation:..
3bd0: 3c 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 74 61 62 <ul>..<li><b>tab
3be0: 6c 65 5f 6e 61 6d 65 3c 2f 62 3e 20 28 3c 69 3e le_name</b> (<i>
3bf0: 3c 62 3e 6d 61 6e 64 61 74 6f 72 79 3c 2f 62 3e <b>mandatory</b>
3c00: 3c 2f 69 3e 29 3a 20 74 68 65 20 6e 61 6d 65 20 </i>): the name
3c10: 6f 66 20 74 68 65 20 54 61 62 6c 65 20 69 6e 20 of the Table in
3c20: 74 68 65 20 63 75 72 72 65 6e 74 20 44 61 74 61 the current Data
3c30: 62 61 73 65 20 63 6f 6e 74 61 69 6e 69 6e 67 20 base containing
3c40: 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 46 44 4f 20 one or more FDO
3c50: 47 65 6f 6d 65 74 72 79 20 43 6f 6c 75 6d 6e 73 Geometry Columns
3c60: 20 74 6f 20 62 65 20 61 75 74 6f 6d 61 74 69 63 to be automatic
3c70: 61 6c 6c 79 20 74 72 61 6e 73 6c 61 74 65 64 20 ally translated
3c80: 74 6f 2f 66 72 6f 6d 20 53 70 61 74 69 61 4c 69 to/from SpatiaLi
3c90: 74 65 27 73 20 6f 77 6e 20 6e 61 74 69 76 65 20 te's own native
3ca0: 62 69 6e 61 72 79 20 42 4c 4f 42 2d 66 6f 72 6d binary BLOB-form
3cb0: 61 74 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c at.</li>..</ul><
3cc0: 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f br>..<table bgco
3cd0: 6c 6f 72 3d 22 23 66 66 66 66 64 30 22 20 63 65 lor="#ffffd0" ce
3ce0: 6c 6c 70 61 64 64 69 6e 67 3d 22 31 38 22 3e 3c llpadding="18"><
3cf0: 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 4e 6f 74 65 tr><td>..<b>Note
3d00: 3c 2f 62 3e 3a 20 71 75 6f 74 69 6e 67 20 6f 72 </b>: quoting or
3d10: 20 6e 6f 74 20 61 6e 79 20 54 65 78 74 20 53 74 not any Text St
3d20: 72 69 6e 67 20 77 68 65 6e 20 69 74 20 61 70 70 ring when it app
3d30: 65 61 72 73 20 61 73 20 61 20 56 69 72 74 75 61 ears as a Virtua
3d40: 6c 20 54 61 62 6c 65 20 61 72 67 75 6d 65 6e 74 l Table argument
3d50: 20 68 61 73 20 61 62 73 6f 6c 75 74 65 6c 79 20 has absolutely
3d60: 6e 6f 20 65 66 66 65 63 74 2e 0d 0a 3c 76 65 72 no effect...<ver
3d70: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 batim>..SELECT C
3d80: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA
3d90: 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 BLE my_table USI
3da0: 4e 47 20 56 69 72 74 75 61 6c 46 64 6f 28 20 6d NG VirtualFdo( m
3db0: 79 5f 70 61 72 63 65 6c 73 20 29 3b 0d 0a 6f 72 y_parcels );..or
3dc0: 0d 0a 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 ..SELECT CREATE
3dd0: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 VIRTUAL TABLE my
3de0: 5f 74 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 _table USING Vir
3df0: 74 75 61 6c 46 64 6f 28 20 27 6d 79 5f 70 61 72 tualFdo( 'my_par
3e00: 63 65 6c 73 27 20 29 3b 0d 0a 3c 2f 76 65 72 62 cels' );..</verb
3e10: 61 74 69 6d 3e 0d 0a 42 6f 74 68 20 6e 6f 74 61 atim>..Both nota
3e20: 74 69 6f 6e 73 20 77 69 6c 6c 20 70 72 6f 64 75 tions will produ
3e30: 63 65 20 65 78 61 63 74 6c 79 20 74 68 65 20 73 ce exactly the s
3e40: 61 6d 65 20 69 64 65 6e 74 69 63 61 6c 20 72 65 ame identical re
3e50: 73 75 6c 74 2e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 sult...</td></tr
3e60: 3e 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e 0d ></table>..<br>.
3e70: 0a 3c 74 61 62 6c 65 20 62 67 63 6f 6c 6f 72 3d .<table bgcolor=
3e80: 22 23 64 30 66 66 64 30 22 20 63 65 6c 6c 70 61 "#d0ffd0" cellpa
3e90: 64 64 69 6e 67 3d 22 31 38 22 3e 3c 74 72 3e 3c dding="18"><tr><
3ea0: 74 64 3e 0d 0a 3c 68 33 3e 42 65 73 74 20 70 72 td>..<h3>Best pr
3eb0: 61 63 74 69 63 65 73 20 61 6e 64 20 6b 6e 6f 77 actices and know
3ec0: 6e 20 6c 69 6d 69 74 61 74 69 6f 6e 73 3c 2f 68 n limitations</h
3ed0: 33 3e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 56 69 3>..<ul>..<li>Vi
3ee0: 72 74 75 61 6c 20 54 61 62 6c 65 73 20 61 72 65 rtual Tables are
3ef0: 20 6e 6f 74 20 72 65 61 6c 6c 79 20 67 65 6e 75 not really genu
3f00: 69 6e 65 20 44 61 74 61 62 61 73 65 20 54 61 62 ine Database Tab
3f10: 6c 65 73 2c 20 74 68 65 79 20 61 72 65 20 6a 75 les, they are ju
3f20: 73 74 20 70 72 65 74 65 6e 64 69 6e 67 20 74 6f st pretending to
3f30: 20 62 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 56 be.</li>..<li>V
3f40: 69 72 74 75 61 6c 20 54 61 62 6c 65 73 20 68 61 irtual Tables ha
3f50: 76 65 20 76 65 72 79 20 70 6f 6f 72 20 73 70 65 ve very poor spe
3f60: 65 64 20 70 65 72 66 6f 72 6d 61 6e 63 65 73 20 ed performances
3f70: 77 68 65 6e 20 63 6f 6d 70 61 72 65 64 20 74 6f when compared to
3f80: 20 67 65 6e 75 69 6e 65 20 44 61 74 61 62 61 73 genuine Databas
3f90: 65 20 54 61 62 6c 65 73 2e 3c 2f 6c 69 3e 0d 0a e Tables.</li>..
3fa0: 3c 6c 69 3e 43 6f 6d 70 6c 65 78 20 53 51 4c 20 <li>Complex SQL
3fb0: 71 75 65 72 69 65 73 20 3c 62 3e 4a 4f 49 4e 3c queries <b>JOIN<
3fc0: 2f 62 3e 69 6e 67 20 73 65 76 65 72 61 6c 20 54 /b>ing several T
3fd0: 61 62 6c 65 73 20 63 61 6e 20 6f 66 74 65 6e 20 ables can often
3fe0: 72 65 74 75 72 6e 20 6f 64 64 20 61 6e 64 20 6d return odd and m
3ff0: 69 73 6c 65 61 64 69 6e 67 20 72 65 73 75 6c 74 isleading result
4000: 73 65 74 73 2c 20 69 66 20 6f 6e 65 20 6f 72 20 sets, if one or
4010: 6d 6f 72 65 20 6f 66 20 74 68 65 20 3c 62 3e 4a more of the <b>J
4020: 4f 49 4e 3c 2f 62 3e 65 64 20 54 61 62 6c 65 73 OIN</b>ed Tables
4030: 20 61 72 65 20 6f 66 20 74 68 65 20 56 69 72 74 are of the Virt
4040: 75 61 6c 20 74 79 70 65 2e 3c 2f 6c 69 3e 0d 0a ual type.</li>..
4050: 3c 6c 69 3e 54 68 65 20 62 65 73 74 20 75 73 61 <li>The best usa
4060: 67 65 20 79 6f 75 20 63 61 6e 20 64 6f 20 6f 66 ge you can do of
4070: 20 61 20 56 69 72 74 75 61 6c 20 54 61 62 6c 65 a Virtual Table
4080: 20 69 73 20 74 6f 20 6a 75 73 74 20 73 75 70 70 is to just supp
4090: 6f 72 74 20 62 61 73 69 63 20 64 61 74 61 20 69 ort basic data i
40a0: 6d 70 6f 72 74 20 70 72 6f 63 65 73 73 65 73 2c mport processes,
40b0: 20 6f 72 20 74 6f 20 71 75 69 63 6b 6c 79 20 67 or to quickly g
40c0: 65 74 20 61 6e 20 6f 76 65 72 61 6c 6c 20 67 6c et an overall gl
40d0: 61 6e 63 65 20 61 74 20 61 20 66 75 6c 6c 20 64 ance at a full d
40e0: 61 74 61 73 65 74 20 77 69 74 68 6f 75 74 20 6e ataset without n
40f0: 65 63 65 73 73 61 72 69 6c 79 20 69 6d 70 6f 72 ecessarily impor
4100: 74 69 6e 67 20 69 74 20 69 6e 74 6f 20 74 68 65 ting it into the
4110: 20 44 61 74 61 62 61 73 65 2e 3c 2f 6c 69 3e 0d Database.</li>.
4120: 0a 3c 6c 69 3e 50 72 65 74 65 6e 64 69 6e 67 20 .<li>Pretending
4130: 74 6f 20 75 73 65 20 61 20 56 69 72 74 75 61 6c to use a Virtual
4140: 20 54 61 62 6c 65 20 61 73 20 61 20 66 75 6c 6c Table as a full
4150: 20 72 65 70 6c 61 63 65 6d 65 6e 74 20 6f 66 20 replacement of
4160: 69 6d 70 6f 72 74 69 6e 67 20 61 6c 6c 20 64 61 importing all da
4170: 74 61 20 77 69 74 68 69 6e 20 61 20 67 65 6e 75 ta within a genu
4180: 69 6e 65 20 44 61 74 61 62 61 73 65 20 54 61 62 ine Database Tab
4190: 6c 65 20 69 73 20 73 74 72 6f 6e 67 6c 79 20 64 le is strongly d
41a0: 69 73 63 6f 75 72 61 67 65 64 2c 20 61 6e 64 20 iscouraged, and
41b0: 6e 65 76 65 72 20 69 73 20 61 20 73 6d 61 72 74 never is a smart
41c0: 20 69 64 65 61 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 idea.</li>..</u
41d0: 6c 3e 3c 62 72 3e 0d 0a 3c 62 3e 4e 6f 74 65 3c l><br>..<b>Note<
41e0: 2f 62 3e 3a 20 56 69 72 74 75 61 6c 46 44 4f 20 /b>: VirtualFDO
41f0: 54 61 62 6c 65 73 20 73 75 70 70 6f 72 74 20 75 Tables support u
4200: 6e 72 65 73 74 72 69 63 74 65 64 20 3c 62 3e 52 nrestricted <b>R
4210: 45 41 44 2d 57 52 49 54 45 3c 2f 62 3e 20 6f 70 EAD-WRITE</b> op
4220: 65 72 61 74 69 6f 6e 73 2c 20 74 68 69 73 20 69 erations, this i
4230: 6e 63 6c 75 64 69 6e 67 20 65 78 65 63 75 74 69 ncluding executi
4240: 6e 67 20 3c 62 3e 49 4e 53 45 52 54 3c 2f 62 3e ng <b>INSERT</b>
4250: 2c 20 3c 62 3e 55 50 44 41 54 45 3c 2f 62 3e 20 , <b>UPDATE</b>
4260: 61 6e 64 20 3c 62 3e 44 45 4c 45 54 45 3c 2f 62 and <b>DELETE</b
4270: 3e 20 73 74 61 74 65 6d 65 6e 74 73 2e 3c 62 72 > statements.<br
4280: 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 >..</td></tr></t
4290: 61 62 6c 65 3e 0d 0a 3c 62 72 3e 0d 0a 3c 68 72 able>..<br>..<hr
42a0: 3e 0d 0a 3c 68 31 3e 3c 61 20 69 64 3d 22 56 69 >..<h1><a id="Vi
42b0: 72 74 75 61 6c 47 50 4b 47 22 3e 56 69 72 74 75 rtualGPKG">Virtu
42c0: 61 6c 47 50 4b 47 3c 2f 61 3e 3c 2f 68 31 3e 0d alGPKG</a></h1>.
42d0: 0a 54 68 65 20 3c 62 3e 56 69 72 74 75 61 6c 47 .The <b>VirtualG
42e0: 50 4b 47 3c 2f 62 3e 20 49 6e 74 65 72 66 61 63 PKG</b> Interfac
42f0: 65 20 61 6c 6c 6f 77 73 20 74 6f 20 64 69 72 65 e allows to dire
4300: 63 74 6c 79 20 61 63 63 65 73 73 20 53 70 61 74 ctly access Spat
4310: 69 61 6c 20 54 61 62 6c 65 73 20 66 72 6f 6d 20 ial Tables from
4320: 61 20 3c 62 3e 47 65 6f 50 61 63 6b 61 67 65 20 a <b>GeoPackage
4330: 44 61 74 61 62 61 73 65 3c 2f 62 3e 20 65 78 61 Database</b> exa
4340: 63 74 6c 79 20 61 73 20 69 66 20 77 61 73 20 61 ctly as if was a
4350: 20 53 70 61 74 69 61 4c 69 74 65 27 73 20 6f 77 SpatiaLite's ow
4360: 6e 20 6e 61 74 69 76 65 20 44 61 74 61 62 61 73 n native Databas
4370: 65 2e 3c 62 72 3e 0d 0a 47 65 6f 50 61 63 6b 61 e.<br>..GeoPacka
4380: 67 65 20 28 3c 69 3e 61 6b 61 3c 2f 69 3e 20 3c ge (<i>aka</i> <
4390: 62 3e 47 50 4b 47 3c 2f 62 3e 29 20 69 73 20 61 b>GPKG</b>) is a
43a0: 6e 20 61 6c 74 65 72 6e 61 74 69 76 65 20 53 70 n alternative Sp
43b0: 61 74 69 61 6c 20 44 61 74 61 62 61 73 65 20 62 atial Database b
43c0: 75 69 6c 74 20 6f 6e 20 74 68 65 20 74 6f 70 20 uilt on the top
43d0: 6f 66 20 53 51 4c 69 74 65 3b 20 79 6f 75 20 63 of SQLite; you c
43e0: 61 6e 20 65 76 65 6e 74 75 61 6c 6c 79 20 72 65 an eventually re
43f0: 61 64 20 74 68 65 20 3c 61 20 68 72 65 66 3d 22 ad the <a href="
4400: 68 74 74 70 3a 2f 2f 77 77 77 2e 67 65 6f 70 61 http://www.geopa
4410: 63 6b 61 67 65 2e 6f 72 67 2f 67 75 69 64 61 6e ckage.org/guidan
4420: 63 65 2f 67 65 74 74 69 6e 67 2d 73 74 61 72 74 ce/getting-start
4430: 65 64 2e 68 74 6d 6c 22 3e 6f 66 66 69 63 69 61 ed.html">officia
4440: 6c 20 73 70 65 63 69 66 69 63 61 74 69 6f 6e 3c l specification<
4450: 2f 61 3e 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 /a> for more det
4460: 61 69 6c 73 2e 3c 62 72 3e 0d 0a 53 79 6e 74 61 ails.<br>..Synta
4470: 78 20 66 6f 72 20 63 72 65 61 74 69 6e 67 20 61 x for creating a
4480: 20 56 69 72 74 75 61 6c 46 44 4f 20 54 61 62 6c VirtualFDO Tabl
4490: 65 3a 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a e:..<verbatim>..
44a0: 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 SELECT CREATE VI
44b0: 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 RTUAL TABLE my_t
44c0: 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 able USING Virtu
44d0: 61 6c 47 70 6b 67 20 28 20 74 61 62 6c 65 5f 6e alGpkg ( table_n
44e0: 61 6d 65 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 ame );..</verbat
44f0: 69 6d 3e 0d 0a 53 75 70 70 6f 72 74 65 64 20 61 im>..Supported a
4500: 72 67 75 6d 65 6e 74 20 61 6e 64 20 69 74 73 20 rgument and its
4510: 69 6e 74 65 72 70 72 65 74 61 74 69 6f 6e 3a 0d interpretation:.
4520: 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 74 61 .<ul>..<li><b>ta
4530: 62 6c 65 5f 6e 61 6d 65 3c 2f 62 3e 20 28 3c 69 ble_name</b> (<i
4540: 3e 3c 62 3e 6d 61 6e 64 61 74 6f 72 79 3c 2f 62 ><b>mandatory</b
4550: 3e 3c 2f 69 3e 29 3a 20 74 68 65 20 6e 61 6d 65 ></i>): the name
4560: 20 6f 66 20 74 68 65 20 54 61 62 6c 65 20 69 6e of the Table in
4570: 20 74 68 65 20 63 75 72 72 65 6e 74 20 44 61 74 the current Dat
4580: 61 62 61 73 65 20 63 6f 6e 74 61 69 6e 69 6e 67 abase containing
4590: 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 47 50 4b one or more GPK
45a0: 47 20 47 65 6f 6d 65 74 72 79 20 43 6f 6c 75 6d G Geometry Colum
45b0: 6e 73 20 74 6f 20 62 65 20 61 75 74 6f 6d 61 74 ns to be automat
45c0: 69 63 61 6c 6c 79 20 74 72 61 6e 73 6c 61 74 65 ically translate
45d0: 64 20 74 6f 2f 66 72 6f 6d 20 53 70 61 74 69 61 d to/from Spatia
45e0: 4c 69 74 65 27 73 20 6f 77 6e 20 6e 61 74 69 76 Lite's own nativ
45f0: 65 20 62 69 6e 61 72 79 20 42 4c 4f 42 2d 66 6f e binary BLOB-fo
4600: 72 6d 61 74 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c rmat.</li>..</ul
4610: 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 ><br>..<table bg
4620: 63 6f 6c 6f 72 3d 22 23 66 66 66 66 64 30 22 20 color="#ffffd0"
4630: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 31 38 22 cellpadding="18"
4640: 3e 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 4e 6f ><tr><td>..<b>No
4650: 74 65 3c 2f 62 3e 3a 20 71 75 6f 74 69 6e 67 20 te</b>: quoting
4660: 6f 72 20 6e 6f 74 20 61 6e 79 20 54 65 78 74 20 or not any Text
4670: 53 74 72 69 6e 67 20 77 68 65 6e 20 69 74 20 61 String when it a
4680: 70 70 65 61 72 73 20 61 73 20 61 20 56 69 72 74 ppears as a Virt
4690: 75 61 6c 20 54 61 62 6c 65 20 61 72 67 75 6d 65 ual Table argume
46a0: 6e 74 20 68 61 73 20 61 62 73 6f 6c 75 74 65 6c nt has absolutel
46b0: 79 20 6e 6f 20 65 66 66 65 63 74 2e 0d 0a 3c 76 y no effect...<v
46c0: 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 erbatim>..SELECT
46d0: 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 CREATE VIRTUAL
46e0: 54 41 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 TABLE my_table U
46f0: 53 49 4e 47 20 56 69 72 74 75 61 6c 47 70 6b 73 SING VirtualGpks
4700: 28 20 6d 79 5f 70 61 72 63 65 6c 73 20 29 3b 0d ( my_parcels );.
4710: 0a 6f 72 0d 0a 53 45 4c 45 43 54 20 43 52 45 41 .or..SELECT CREA
4720: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 TE VIRTUAL TABLE
4730: 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 4e 47 20 my_table USING
4740: 56 69 72 74 75 61 6c 47 70 6b 67 28 20 27 6d 79 VirtualGpkg( 'my
4750: 5f 70 61 72 63 65 6c 73 27 20 29 3b 0d 0a 3c 2f _parcels' );..</
4760: 76 65 72 62 61 74 69 6d 3e 0d 0a 42 6f 74 68 20 verbatim>..Both
4770: 6e 6f 74 61 74 69 6f 6e 73 20 77 69 6c 6c 20 70 notations will p
4780: 72 6f 64 75 63 65 20 65 78 61 63 74 6c 79 20 74 roduce exactly t
4790: 68 65 20 73 61 6d 65 20 69 64 65 6e 74 69 63 61 he same identica
47a0: 6c 20 72 65 73 75 6c 74 2e 0d 0a 3c 2f 74 64 3e l result...</td>
47b0: 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 0d 0a 3c </tr></table>..<
47c0: 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f br>..<table bgco
47d0: 6c 6f 72 3d 22 23 64 30 66 66 64 30 22 20 63 65 lor="#d0ffd0" ce
47e0: 6c 6c 70 61 64 64 69 6e 67 3d 22 31 38 22 3e 3c llpadding="18"><
47f0: 74 72 3e 3c 74 64 3e 0d 0a 3c 68 33 3e 42 65 73 tr><td>..<h3>Bes
4800: 74 20 70 72 61 63 74 69 63 65 73 20 61 6e 64 20 t practices and
4810: 6b 6e 6f 77 6e 20 6c 69 6d 69 74 61 74 69 6f 6e known limitation
4820: 73 3c 2f 68 33 3e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c s</h3>..<ul>..<l
4830: 69 3e 56 69 72 74 75 61 6c 20 54 61 62 6c 65 73 i>Virtual Tables
4840: 20 61 72 65 20 6e 6f 74 20 72 65 61 6c 6c 79 20 are not really
4850: 67 65 6e 75 69 6e 65 20 44 61 74 61 62 61 73 65 genuine Database
4860: 20 54 61 62 6c 65 73 2c 20 74 68 65 79 20 61 72 Tables, they ar
4870: 65 20 6a 75 73 74 20 70 72 65 74 65 6e 64 69 6e e just pretendin
4880: 67 20 74 6f 20 62 65 2e 3c 2f 6c 69 3e 0d 0a 3c g to be.</li>..<
4890: 6c 69 3e 56 69 72 74 75 61 6c 20 54 61 62 6c 65 li>Virtual Table
48a0: 73 20 68 61 76 65 20 76 65 72 79 20 70 6f 6f 72 s have very poor
48b0: 20 73 70 65 65 64 20 70 65 72 66 6f 72 6d 61 6e speed performan
48c0: 63 65 73 20 77 68 65 6e 20 63 6f 6d 70 61 72 65 ces when compare
48d0: 64 20 74 6f 20 67 65 6e 75 69 6e 65 20 44 61 74 d to genuine Dat
48e0: 61 62 61 73 65 20 54 61 62 6c 65 73 2e 3c 2f 6c abase Tables.</l
48f0: 69 3e 0d 0a 3c 6c 69 3e 43 6f 6d 70 6c 65 78 20 i>..<li>Complex
4900: 53 51 4c 20 71 75 65 72 69 65 73 20 3c 62 3e 4a SQL queries <b>J
4910: 4f 49 4e 3c 2f 62 3e 69 6e 67 20 73 65 76 65 72 OIN</b>ing sever
4920: 61 6c 20 54 61 62 6c 65 73 20 63 61 6e 20 6f 66 al Tables can of
4930: 74 65 6e 20 72 65 74 75 72 6e 20 6f 64 64 20 61 ten return odd a
4940: 6e 64 20 6d 69 73 6c 65 61 64 69 6e 67 20 72 65 nd misleading re
4950: 73 75 6c 74 73 65 74 73 2c 20 69 66 20 6f 6e 65 sultsets, if one
4960: 20 6f 72 20 6d 6f 72 65 20 6f 66 20 74 68 65 20 or more of the
4970: 3c 62 3e 4a 4f 49 4e 3c 2f 62 3e 65 64 20 54 61 <b>JOIN</b>ed Ta
4980: 62 6c 65 73 20 61 72 65 20 6f 66 20 74 68 65 20 bles are of the
4990: 56 69 72 74 75 61 6c 20 74 79 70 65 2e 3c 2f 6c Virtual type.</l
49a0: 69 3e 0d 0a 3c 6c 69 3e 54 68 65 20 62 65 73 74 i>..<li>The best
49b0: 20 75 73 61 67 65 20 79 6f 75 20 63 61 6e 20 64 usage you can d
49c0: 6f 20 6f 66 20 61 20 56 69 72 74 75 61 6c 20 54 o of a Virtual T
49d0: 61 62 6c 65 20 69 73 20 74 6f 20 6a 75 73 74 20 able is to just
49e0: 73 75 70 70 6f 72 74 20 62 61 73 69 63 20 64 61 support basic da
49f0: 74 61 20 69 6d 70 6f 72 74 20 70 72 6f 63 65 73 ta import proces
4a00: 73 65 73 2c 20 6f 72 20 74 6f 20 71 75 69 63 6b ses, or to quick
4a10: 6c 79 20 67 65 74 20 61 6e 20 6f 76 65 72 61 6c ly get an overal
4a20: 6c 20 67 6c 61 6e 63 65 20 61 74 20 61 20 66 75 l glance at a fu
4a30: 6c 6c 20 64 61 74 61 73 65 74 20 77 69 74 68 6f ll dataset witho
4a40: 75 74 20 6e 65 63 65 73 73 61 72 69 6c 79 20 69 ut necessarily i
4a50: 6d 70 6f 72 74 69 6e 67 20 69 74 20 69 6e 74 6f mporting it into
4a60: 20 74 68 65 20 44 61 74 61 62 61 73 65 2e 3c 2f the Database.</
4a70: 6c 69 3e 0d 0a 3c 6c 69 3e 50 72 65 74 65 6e 64 li>..<li>Pretend
4a80: 69 6e 67 20 74 6f 20 75 73 65 20 61 20 56 69 72 ing to use a Vir
4a90: 74 75 61 6c 20 54 61 62 6c 65 20 61 73 20 61 20 tual Table as a
4aa0: 66 75 6c 6c 20 72 65 70 6c 61 63 65 6d 65 6e 74 full replacement
4ab0: 20 6f 66 20 69 6d 70 6f 72 74 69 6e 67 20 61 6c of importing al
4ac0: 6c 20 64 61 74 61 20 77 69 74 68 69 6e 20 61 20 l data within a
4ad0: 67 65 6e 75 69 6e 65 20 44 61 74 61 62 61 73 65 genuine Database
4ae0: 20 54 61 62 6c 65 20 69 73 20 73 74 72 6f 6e 67 Table is strong
4af0: 6c 79 20 64 69 73 63 6f 75 72 61 67 65 64 2c 20 ly discouraged,
4b00: 61 6e 64 20 6e 65 76 65 72 20 69 73 20 61 20 73 and never is a s
4b10: 6d 61 72 74 20 69 64 65 61 2e 3c 2f 6c 69 3e 0d mart idea.</li>.
4b20: 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 62 3e 4e .</ul><br>..<b>N
4b30: 6f 74 65 3c 2f 62 3e 3a 20 56 69 72 74 75 61 6c ote</b>: Virtual
4b40: 47 50 4b 47 20 54 61 62 6c 65 73 20 73 75 70 70 GPKG Tables supp
4b50: 6f 72 74 20 75 6e 72 65 73 74 72 69 63 74 65 64 ort unrestricted
4b60: 20 3c 62 3e 52 45 41 44 2d 57 52 49 54 45 3c 2f <b>READ-WRITE</
4b70: 62 3e 20 6f 70 65 72 61 74 69 6f 6e 73 2c 20 74 b> operations, t
4b80: 68 69 73 20 69 6e 63 6c 75 64 69 6e 67 20 65 78 his including ex
4b90: 65 63 75 74 69 6e 67 20 3c 62 3e 49 4e 53 45 52 ecuting <b>INSER
4ba0: 54 3c 2f 62 3e 2c 20 3c 62 3e 55 50 44 41 54 45 T</b>, <b>UPDATE
4bb0: 3c 2f 62 3e 20 61 6e 64 20 3c 62 3e 44 45 4c 45 </b> and <b>DELE
4bc0: 54 45 3c 2f 62 3e 20 73 74 61 74 65 6d 65 6e 74 TE</b> statement
4bd0: 73 2e 3c 62 72 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 s.<br>..</td></t
4be0: 72 3e 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e r></table>..<br>
4bf0: 0d 0a 3c 68 72 3e 0d 0a 3c 62 72 3e 0d 0a 3c 61 ..<hr>..<br>..<a
4c00: 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 href="https://w
4c10: 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 66 ww.gaia-gis.it/f
4c20: 6f 73 73 69 6c 2f 6c 69 62 73 70 61 74 69 61 6c ossil/libspatial
4c30: 69 74 65 2f 68 6f 6d 65 22 3e 62 61 63 6b 20 74 ite/home">back t
4c40: 6f 20 6d 61 69 6e 20 70 61 67 65 3c 2f 61 3e 0a o main page</a>.
4c50: 5a 20 36 39 66 39 39 36 36 65 32 34 32 34 33 64 Z 69f9966e24243d
4c60: 39 34 38 64 38 61 31 65 33 34 30 36 33 66 63 62 948d8a1e34063fcb
4c70: 34 30 0a 40.