Artifact
c14fe1d90e3238e66d8c5e1b1690a50c316e8d30:
Wiki page
[Virtual Tables (misc)] by
sandro
2018-08-21 18:17:34.
0000: 44 20 32 30 31 38 2d 30 38 2d 32 31 54 31 38 3a D 2018-08-21T18:
0010: 31 37 3a 33 34 2e 37 34 37 0a 4c 20 56 69 72 74 17:34.747.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 55 20 73 61 6e 64 72 6f 0a 57 20 36 sc).U sandro.W 6
0040: 32 38 38 0a 3c 61 20 68 72 65 66 3d 22 68 74 74 288.<a href="htt
0050: 70 73 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 ps://www.gaia-gi
0060: 73 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c 69 62 73 s.it/fossil/libs
0070: 70 61 74 69 61 6c 69 74 65 2f 68 6f 6d 65 22 3e patialite/home">
0080: 62 61 63 6b 20 74 6f 20 6d 61 69 6e 20 70 61 67 back to main pag
0090: 65 3c 2f 61 3e 0d 0a 3c 68 31 3e 56 69 72 74 75 e</a>..<h1>Virtu
00a0: 61 6c 53 68 61 70 65 3c 2f 68 31 3e 0d 0a 54 68 alShape</h1>..Th
00b0: 65 20 3c 62 3e 56 69 72 74 75 61 6c 53 68 61 70 e <b>VirtualShap
00c0: 65 3c 2f 62 3e 20 49 6e 74 65 72 66 61 63 65 20 e</b> Interface
00d0: 61 6c 6c 6f 77 73 20 74 6f 20 64 69 72 65 63 74 allows to direct
00e0: 6c 79 20 61 63 63 65 73 73 20 61 6e 20 65 78 74 ly access an ext
00f0: 65 72 6e 61 6c 20 53 68 61 70 65 46 69 6c 65 20 ernal ShapeFile
0100: 62 79 20 75 73 69 6e 67 20 73 74 61 6e 64 61 72 by using standar
0110: 64 20 53 70 61 74 69 61 6c 20 53 51 4c 20 71 75 d Spatial SQL qu
0120: 65 72 69 65 73 2e 3c 62 72 3e 0d 0a 53 79 6e 74 eries.<br>..Synt
0130: 61 78 20 66 6f 72 20 63 72 65 61 74 69 6e 67 20 ax for creating
0140: 61 20 56 69 72 74 75 61 6c 53 68 61 70 65 20 54 a VirtualShape T
0150: 61 62 6c 65 3a 0d 0a 3c 76 65 72 62 61 74 69 6d able:..<verbatim
0160: 3e 0d 0a 53 45 4c 45 43 54 20 43 52 45 41 54 45 >..SELECT CREATE
0170: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 6d VIRTUAL TABLE m
0180: 79 5f 74 61 62 6c 65 20 55 53 49 4e 47 20 56 69 y_table USING Vi
0190: 72 74 75 61 6c 53 68 61 70 65 20 28 20 73 68 70 rtualShape ( shp
01a0: 5f 70 61 74 68 20 2c 20 63 68 61 72 73 65 74 5f _path , charset_
01b0: 65 6e 63 6f 64 69 6e 67 20 2c 20 73 72 69 64 20 encoding , srid
01c0: 29 3b 0d 0a 0d 0a 53 45 4c 45 43 54 20 43 52 45 );....SELECT CRE
01d0: 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c ATE VIRTUAL TABL
01e0: 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 4e 47 E my_table USING
01f0: 20 56 69 72 74 75 61 6c 53 68 61 70 65 20 28 20 VirtualShape (
0200: 73 68 70 5f 70 61 74 68 20 2c 20 63 68 61 72 73 shp_path , chars
0210: 65 74 5f 65 6e 63 6f 64 69 6e 67 20 2c 20 73 72 et_encoding , sr
0220: 69 64 20 2c 20 74 65 78 74 5f 64 61 74 65 73 20 id , text_dates
0230: 29 3b 0d 0a 0d 0a 53 45 4c 45 43 54 20 43 52 45 );....SELECT CRE
0240: 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c ATE VIRTUAL TABL
0250: 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 4e 47 E my_table USING
0260: 20 56 69 72 74 75 61 6c 53 68 61 70 65 20 28 20 VirtualShape (
0270: 73 68 70 5f 70 61 74 68 20 2c 20 63 68 61 72 73 shp_path , chars
0280: 65 74 5f 65 6e 63 6f 64 69 6e 67 20 2c 20 73 72 et_encoding , sr
0290: 69 64 20 2c 20 74 65 78 74 5f 64 61 74 65 73 20 id , text_dates
02a0: 2c 20 63 6f 6c 6e 61 6d 65 5f 63 61 73 65 20 29 , colname_case )
02b0: 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a ;..</verbatim>..
02c0: 53 75 70 70 6f 72 74 65 64 20 61 72 67 75 6d 65 Supported argume
02d0: 6e 74 73 20 61 6e 64 20 74 68 65 69 72 20 69 6e nts and their in
02e0: 74 65 72 70 72 65 74 61 74 69 6f 6e 3a 0d 0a 3c terpretation:..<
02f0: 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 73 68 70 5f ul>..<li><b>shp_
0300: 70 61 74 68 3c 2f 62 3e 20 28 3c 69 3e 3c 62 3e path</b> (<i><b>
0310: 6d 61 6e 64 61 74 6f 72 79 3c 2f 62 3e 3c 2f 69 mandatory</b></i
0320: 3e 29 3a 20 74 68 65 20 72 65 6c 61 74 69 76 65 >): the relative
0330: 20 6f 72 20 61 62 73 6f 6c 75 74 65 20 70 61 74 or absolute pat
0340: 68 6e 61 6d 65 20 6c 65 61 64 69 6e 67 20 74 6f hname leading to
0350: 20 74 68 65 20 65 78 74 65 72 6e 61 6c 65 20 53 the externale S
0360: 68 61 70 65 66 69 6c 65 2e 0d 0a 3c 75 6c 3e 0d hapefile...<ul>.
0370: 0a 3c 6c 69 3e 3c 62 3e 4e 6f 74 65 3c 2f 62 3e .<li><b>Note</b>
0380: 3a 20 61 6e 79 20 53 68 61 70 65 66 69 6c 65 20 : any Shapefile
0390: 72 65 71 75 69 72 65 73 20 61 74 20 6c 65 61 73 requires at leas
03a0: 74 20 74 68 72 65 65 20 69 6e 64 69 76 69 64 75 t three individu
03b0: 61 6c 20 6d 65 6d 62 65 72 73 20 73 68 61 72 69 al members shari
03c0: 6e 67 20 74 68 65 20 73 61 6d 65 20 62 61 73 65 ng the same base
03d0: 20 6e 61 6d 65 20 62 75 74 20 77 69 74 68 20 64 name but with d
03e0: 69 66 66 65 72 65 6e 74 20 73 75 66 66 69 78 65 ifferent suffixe
03f0: 73 20 28 3c 69 3e 2a 2e 73 68 70 3c 2f 69 3e 2c s (<i>*.shp</i>,
0400: 20 3c 69 3e 2a 2e 73 68 78 3c 2f 69 3e 20 61 6e <i>*.shx</i> an
0410: 64 20 3c 69 3e 2a 2e 64 62 66 3c 2f 69 3e 2e 3c d <i>*.dbf</i>.<
0420: 62 72 3e 0d 0a 41 6c 6c 20 73 75 66 66 69 78 65 br>..All suffixe
0430: 73 20 77 69 6c 6c 20 62 65 20 61 75 74 6f 6d 61 s will be automa
0440: 74 69 63 61 6c 6c 79 20 68 61 6e 64 6c 65 64 3b tically handled;
0450: 20 74 68 65 20 3c 62 3e 73 68 70 5f 70 61 74 68 the <b>shp_path
0460: 3c 2f 62 3e 20 61 72 67 75 6d 65 6e 74 20 3c 62 </b> argument <b
0470: 3e 3c 75 3e 3c 69 3e 6d 75 73 74 20 6e 6f 74 20 ><u><i>must not
0480: 73 70 65 63 69 66 79 20 61 6e 79 20 70 72 65 66 specify any pref
0490: 69 78 3c 2f 69 3e 3c 2f 75 3e 3c 2f 62 3e 2c 20 ix</i></u></b>,
04a0: 6a 75 73 74 20 74 68 65 20 62 61 72 65 20 62 61 just the bare ba
04b0: 73 65 20 70 61 74 68 20 6d 75 73 74 20 62 65 20 se path must be
04c0: 70 61 73 73 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 2f passed.</li>..</
04d0: 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 ul></li>..<li><b
04e0: 3e 63 68 61 72 73 65 74 5f 65 6e 63 6f 64 69 6e >charset_encodin
04f0: 67 3c 2f 62 3e 20 28 3c 69 3e 3c 62 3e 6d 61 6e g</b> (<i><b>man
0500: 64 61 74 6f 72 79 3c 2f 62 3e 3c 2f 69 3e 29 3a datory</b></i>):
0510: 20 63 61 6e 6f 6e 69 63 61 6c 20 6e 61 6d 65 20 canonical name
0520: 6f 66 20 74 68 65 20 63 68 61 72 73 65 74 20 65 of the charset e
0530: 6e 63 6f 64 69 6e 67 20 61 64 6f 70 74 65 64 20 ncoding adopted
0540: 62 79 20 74 68 65 20 3c 62 3e 44 42 46 3c 2f 62 by the <b>DBF</b
0550: 3e 20 6d 65 6d 62 65 72 2e 0d 0a 3c 75 6c 3e 0d > member...<ul>.
0560: 0a 3c 6c 69 3e 45 78 61 6d 70 6c 65 73 20 6f 66 .<li>Examples of
0570: 20 76 61 6c 69 64 20 6e 61 6d 65 73 20 61 72 65 valid names are
0580: 3a 20 3c 62 3e 41 53 43 49 49 3c 2f 62 3e 2c 20 : <b>ASCII</b>,
0590: 3c 62 3e 55 54 46 2d 38 3c 2f 62 3e 2c 20 3c 62 <b>UTF-8</b>, <b
05a0: 3e 43 50 38 35 30 3c 2f 62 3e 2c 20 3c 62 3e 49 >CP850</b>, <b>I
05b0: 53 4f 2d 38 38 34 39 2d 31 3c 2f 62 3e 3c 2f 6c SO-8849-1</b></l
05c0: 69 3e 0d 0a 3c 6c 69 3e 59 6f 75 20 63 61 6e 20 i>..<li>You can
05d0: 63 68 65 63 6b 20 74 68 65 20 66 75 6c 6c 20 6c check the full l
05e0: 69 73 74 20 6f 66 20 73 75 70 70 6f 72 74 65 64 ist of supported
05f0: 20 63 68 61 72 73 65 74 20 65 6e 63 6f 64 69 6e charset encodin
0600: 67 73 20 66 72 6f 6d 20 3c 61 20 68 72 65 66 3d gs from <a href=
0610: 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 6e 75 "https://www.gnu
0620: 2e 6f 72 67 2f 73 6f 66 74 77 61 72 65 2f 6c 69 .org/software/li
0630: 62 69 63 6f 6e 76 2f 22 3e 68 65 72 65 3c 2f 61 biconv/">here</a
0640: 3e 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f >.</li>..</ul></
0650: 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e 73 72 69 64 li>..<li><b>srid
0660: 3c 2f 62 3e 20 28 3c 69 3e 3c 62 3e 6d 61 6e 64 </b> (<i><b>mand
0670: 61 74 6f 72 79 3c 2f 62 3e 3c 2f 69 3e 29 3a 20 atory</b></i>):
0680: 74 68 65 20 53 52 49 44 20 76 61 6c 75 65 20 6f the SRID value o
0690: 66 20 61 6c 6c 20 47 65 6f 6d 65 74 72 69 65 73 f all Geometries
06a0: 20 77 69 74 68 69 6e 20 74 68 65 20 53 68 61 70 within the Shap
06b0: 65 66 69 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c efile...<ul>..<l
06c0: 69 3e 45 78 61 6d 70 6c 65 73 20 6f 66 20 76 61 i>Examples of va
06d0: 6c 69 64 20 53 52 49 44 20 76 61 6c 75 65 73 20 lid SRID values
06e0: 61 72 65 3a 20 3c 62 3e 34 33 32 36 3c 2f 62 3e are: <b>4326</b>
06f0: 2c 20 3c 62 3e 33 30 30 33 3c 2f 62 3e 2c 20 3c , <b>3003</b>, <
0700: 62 3e 33 32 36 33 32 3c 2f 62 3e 3c 2f 6c 69 3e b>32632</b></li>
0710: 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 6c ..</ul></li>..<l
0720: 69 3e 3c 62 3e 74 65 78 74 5f 64 61 74 65 73 3c i><b>text_dates<
0730: 2f 62 3e 20 28 3c 69 3e 3c 62 3e 6f 70 74 69 6f /b> (<i><b>optio
0740: 6e 61 6c 3c 2f 62 3e 3c 2f 69 3e 29 3a 20 74 68 nal</b></i>): th
0750: 69 73 20 69 73 20 61 20 3c 62 3e 42 4f 4f 4c 45 is is a <b>BOOLE
0760: 41 4e 3c 2f 62 3e 20 66 6c 61 67 3a 0d 0a 3c 75 AN</b> flag:..<u
0770: 6c 3e 0d 0a 3c 6c 69 3e 69 66 20 73 65 74 20 74 l>..<li>if set t
0780: 6f 20 3c 62 3e 30 3c 2f 62 3e 20 28 3c 62 3e 46 o <b>0</b> (<b>F
0790: 41 4c 53 45 3c 2f 62 3e 29 20 61 6c 6c 20 66 69 ALSE</b>) all fi
07a0: 65 6c 64 73 20 6f 66 20 74 68 65 20 3c 62 3e 44 elds of the <b>D
07b0: 41 54 45 3c 2f 62 3e 20 74 79 70 65 20 77 69 6c ATE</b> type wil
07c0: 6c 20 62 65 20 72 65 70 72 65 73 65 6e 74 65 64 l be represented
07d0: 20 61 73 20 3c 61 20 68 72 65 66 3d 22 68 74 74 as <a href="htt
07e0: 70 73 3a 2f 2f 77 77 77 2e 73 71 6c 69 74 65 2e ps://www.sqlite.
07f0: 6f 72 67 2f 6c 61 6e 67 5f 64 61 74 65 66 75 6e org/lang_datefun
0800: 63 2e 68 74 6d 6c 22 3e 6a 75 6c 69 61 6e 20 64 c.html">julian d
0810: 61 74 65 73 3c 2f 61 3e 3c 2f 6c 69 3e 0d 0a 3c ates</a></li>..<
0820: 6c 69 3e 69 66 20 73 65 74 20 74 6f 20 61 6e 79 li>if set to any
0830: 20 6f 74 68 65 72 20 69 6e 74 65 67 65 72 20 76 other integer v
0840: 61 6c 75 65 20 28 3c 62 3e 54 52 55 45 3c 2f 62 alue (<b>TRUE</b
0850: 3e 29 20 61 6c 6c 20 66 69 65 6c 64 73 20 6f 66 >) all fields of
0860: 20 74 68 65 20 3c 62 3e 44 41 54 45 3c 2f 62 3e the <b>DATE</b>
0870: 20 74 79 70 65 20 77 69 6c 6c 20 62 65 20 72 65 type will be re
0880: 70 72 65 73 65 6e 74 65 64 20 61 73 20 54 65 78 presented as Tex
0890: 74 20 53 74 72 69 6e 67 73 20 61 73 20 65 2e 67 t Strings as e.g
08a0: 2e 20 3c 62 3e 32 30 31 38 2d 30 38 2d 32 31 3c . <b>2018-08-21<
08b0: 2f 62 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 69 66 /b></li>..<li>if
08c0: 20 6e 6f 74 20 65 78 70 6c 69 63 69 74 6c 79 20 not explicitly
08d0: 73 70 65 63 69 66 69 65 64 2c 20 3c 62 3e 54 52 specified, <b>TR
08e0: 55 45 3c 2f 62 3e 20 77 69 6c 6c 20 62 65 20 61 UE</b> will be a
08f0: 6c 77 61 79 73 20 61 73 73 75 6d 65 64 20 28 64 lways assumed (d
0900: 65 66 61 75 6c 74 20 73 65 74 74 69 6e 67 29 2e efault setting).
0910: 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 </li>..</ul></li
0920: 3e 0d 0a 3c 6c 69 3e 3c 62 3e 63 6f 6c 6e 61 6d >..<li><b>colnam
0930: 65 5f 63 61 73 65 3c 2f 62 3e 20 28 3c 69 3e 3c e_case</b> (<i><
0940: 62 3e 6f 70 74 69 6f 6e 61 6c 3c 2f 62 3e 3c 2f b>optional</b></
0950: 69 3e 29 3a 20 74 68 69 73 20 61 72 67 75 6d 65 i>): this argume
0960: 6e 74 20 73 70 65 63 69 66 69 65 73 20 69 66 20 nt specifies if
0970: 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 73 all column names
0980: 20 73 68 6f 75 6c 64 20 62 65 20 75 70 70 65 72 should be upper
0990: 63 61 73 65 20 6f 72 20 6c 6f 77 65 72 63 61 73 case or lowercas
09a0: 65 2e 3c 62 72 3e 0d 0a 56 61 6c 69 64 20 73 65 e.<br>..Valid se
09b0: 74 74 69 6e 67 73 20 61 72 65 3a 0d 0a 3c 75 6c ttings are:..<ul
09c0: 3e 0d 0a 3c 6c 69 3e 3c 62 3e 75 70 70 65 72 63 >..<li><b>upperc
09d0: 61 73 65 3c 2f 62 3e 20 6f 72 20 3c 62 3e 75 70 ase</b> or <b>up
09e0: 70 65 72 3c 2f 62 3e 3a 20 61 6c 6c 20 63 6f 6c per</b>: all col
09f0: 75 6d 6e 20 6e 61 6d 65 73 20 77 69 6c 6c 20 62 umn names will b
0a00: 65 20 66 75 6c 6c 79 20 63 61 70 69 74 61 6c 69 e fully capitali
0a10: 7a 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c zed.</li>..<li><
0a20: 62 3e 6c 6f 77 65 72 63 61 73 65 3c 2f 62 3e 20 b>lowercase</b>
0a30: 6f 72 20 3c 62 3e 6c 6f 77 65 72 3c 2f 62 3e 3a or <b>lower</b>:
0a40: 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 all column name
0a50: 73 20 77 69 6c 6c 20 62 65 20 66 75 6c 6c 20 6c s will be full l
0a60: 6f 77 65 72 63 61 73 65 2e 3c 2f 6c 69 3e 0d 0a owercase.</li>..
0a70: 3c 6c 69 3e 3c 62 3e 73 61 6d 65 63 61 73 65 3c <li><b>samecase<
0a80: 2f 62 3e 20 6f 72 20 3c 62 3e 73 61 6d 65 3c 2f /b> or <b>same</
0a90: 62 3e 3a 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e b>: all column n
0aa0: 61 6d 65 73 20 77 69 6c 6c 20 62 65 20 65 78 61 ames will be exa
0ab0: 63 74 6c 79 20 70 72 65 73 65 72 76 65 64 20 61 ctly preserved a
0ac0: 73 20 74 68 65 79 20 61 72 65 20 64 65 66 69 6e s they are defin
0ad0: 65 64 20 69 6e 74 6f 20 74 68 65 20 44 42 46 20 ed into the DBF
0ae0: 6d 65 6d 65 62 65 72 2e 3c 2f 6c 69 3e 0d 0a 3c memeber.</li>..<
0af0: 6c 69 3e 69 66 20 6e 6f 74 20 73 70 65 63 69 66 li>if not specif
0b00: 69 65 64 2c 20 6f 72 20 69 66 20 61 6e 79 20 6f ied, or if any o
0b10: 74 68 65 72 20 64 65 66 69 6e 69 74 69 6f 6e 20 ther definition
0b20: 64 65 66 69 6e 69 74 69 6f 6e 20 69 73 20 66 6f definition is fo
0b30: 75 6e 64 2c 20 3c 62 3e 75 70 70 65 72 63 61 73 und, <b>uppercas
0b40: 65 3c 2f 62 3e 20 77 69 6c 6c 20 62 65 20 61 6c e</b> will be al
0b50: 77 61 79 73 20 61 73 73 75 6d 65 64 20 28 64 65 ways assumed (de
0b60: 66 61 75 6c 74 20 73 65 74 74 69 6e 67 29 2e 3c fault setting).<
0b70: 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 3e /li>..</ul></li>
0b80: 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 74 61 ..</ul><br>..<ta
0b90: 62 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 23 66 66 ble bgcolor="#ff
0ba0: 66 66 61 30 22 20 63 65 6c 6c 70 61 64 64 69 6e ffa0" cellpaddin
0bb0: 67 3d 22 31 30 22 3e 3c 74 72 3e 3c 74 64 3e 0d g="10"><tr><td>.
0bc0: 0a 3c 62 3e 4e 6f 74 65 3c 2f 62 3e 3a 20 71 75 .<b>Note</b>: qu
0bd0: 6f 74 69 6e 67 20 6f 72 20 6e 6f 74 20 61 6e 79 oting or not any
0be0: 20 54 65 78 74 20 53 74 72 69 6e 67 20 77 68 65 Text String whe
0bf0: 6e 20 69 74 20 61 70 70 65 61 72 73 20 61 73 20 n it appears as
0c00: 61 20 56 69 72 74 75 61 6c 20 54 61 62 6c 65 20 a Virtual Table
0c10: 61 72 67 75 6d 65 6e 74 20 68 61 73 20 61 62 73 argument has abs
0c20: 6f 6c 75 74 65 6c 79 20 6e 6f 20 65 66 66 65 63 olutely no effec
0c30: 74 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a t...<verbatim>..
0c40: 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 SELECT CREATE VI
0c50: 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 RTUAL TABLE my_t
0c60: 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 able USING Virtu
0c70: 61 6c 53 68 61 70 65 28 20 2f 68 6f 6d 65 2f 73 alShape( /home/s
0c80: 61 6e 64 72 6f 2f 6d 79 73 68 70 20 2c 20 43 50 andro/myshp , CP
0c90: 31 32 35 32 20 2c 20 33 30 30 33 20 2c 20 31 20 1252 , 3003 , 1
0ca0: 2c 20 6c 6f 77 65 72 20 29 3b 0d 0a 6f 72 0d 0a , lower );..or..
0cb0: 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 SELECT CREATE VI
0cc0: 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 RTUAL TABLE my_t
0cd0: 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 able USING Virtu
0ce0: 61 6c 53 68 61 70 65 28 20 27 2f 68 6f 6d 65 2f alShape( '/home/
0cf0: 73 61 6e 64 72 6f 2f 6d 79 73 68 70 27 20 2c 20 sandro/myshp' ,
0d00: 27 43 50 31 32 35 32 27 20 2c 20 33 30 30 33 20 'CP1252' , 3003
0d10: 2c 20 31 20 2c 20 27 6c 6f 77 65 72 27 20 29 3b , 1 , 'lower' );
0d20: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 42 ..</verbatim>..B
0d30: 6f 74 68 20 6e 6f 74 61 74 69 6f 6e 73 20 77 69 oth notations wi
0d40: 6c 6c 20 70 72 6f 64 75 63 65 20 65 78 61 63 74 ll produce exact
0d50: 6c 79 20 74 68 65 20 73 61 6d 65 20 69 64 65 6e ly the same iden
0d60: 74 69 63 61 6c 20 72 65 73 75 6c 74 2e 0d 0a 3c tical result...<
0d70: 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 /td></tr></table
0d80: 3e 0d 0a 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c >..<br>..<hr>..<
0d90: 68 31 3e 56 69 72 74 75 61 6c 44 42 46 3c 2f 68 h1>VirtualDBF</h
0da0: 31 3e 0d 0a 54 68 65 20 3c 62 3e 56 69 72 74 75 1>..The <b>Virtu
0db0: 61 6c 44 42 46 3c 2f 62 3e 20 49 6e 74 65 72 66 alDBF</b> Interf
0dc0: 61 63 65 20 61 6c 6c 6f 77 73 20 74 6f 20 64 69 ace allows to di
0dd0: 72 65 63 74 6c 79 20 61 63 63 65 73 73 20 61 6e rectly access an
0de0: 20 65 78 74 65 72 6e 61 6c 20 53 68 61 70 65 46 external ShapeF
0df0: 69 6c 65 20 62 79 20 75 73 69 6e 67 20 73 74 61 ile by using sta
0e00: 6e 64 61 72 64 20 53 70 61 74 69 61 6c 20 53 51 ndard Spatial SQ
0e10: 4c 20 71 75 65 72 69 65 73 2e 3c 62 72 3e 0d 0a L queries.<br>..
0e20: 53 79 6e 74 61 78 20 66 6f 72 20 63 72 65 61 74 Syntax for creat
0e30: 69 6e 67 20 61 20 56 69 72 74 75 61 6c 53 68 61 ing a VirtualSha
0e40: 70 65 20 54 61 62 6c 65 3a 0d 0a 3c 76 65 72 62 pe Table:..<verb
0e50: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 52 atim>..SELECT CR
0e60: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
0e70: 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 4e LE my_table USIN
0e80: 47 20 56 69 72 74 75 61 6c 44 62 66 20 28 20 64 G VirtualDbf ( d
0e90: 62 66 5f 70 61 74 68 20 2c 20 63 68 61 72 73 65 bf_path , charse
0ea0: 74 5f 65 6e 63 6f 64 69 6e 67 20 29 3b 0d 0a 0d t_encoding );...
0eb0: 0a 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 .SELECT CREATE V
0ec0: 49 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f IRTUAL TABLE my_
0ed0: 74 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 table USING Virt
0ee0: 75 61 6c 44 62 66 20 28 20 64 62 66 5f 70 61 74 ualDbf ( dbf_pat
0ef0: 68 20 2c 20 63 68 61 72 73 65 74 5f 65 6e 63 6f h , charset_enco
0f00: 64 69 6e 67 20 2c 20 74 65 78 74 5f 64 61 74 65 ding , text_date
0f10: 73 20 29 3b 0d 0a 0d 0a 53 45 4c 45 43 54 20 43 s );....SELECT C
0f20: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA
0f30: 42 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 BLE my_table USI
0f40: 4e 47 20 56 69 72 74 75 61 6c 44 62 66 20 28 20 NG VirtualDbf (
0f50: 64 62 66 5f 70 61 74 68 20 2c 20 63 68 61 72 73 dbf_path , chars
0f60: 65 74 5f 65 6e 63 6f 64 69 6e 67 20 2c 20 74 65 et_encoding , te
0f70: 78 74 5f 64 61 74 65 73 20 2c 20 63 6f 6c 6e 61 xt_dates , colna
0f80: 6d 65 5f 63 61 73 65 20 29 3b 0d 0a 3c 2f 76 65 me_case );..</ve
0f90: 72 62 61 74 69 6d 3e 0d 0a 53 75 70 70 6f 72 74 rbatim>..Support
0fa0: 65 64 20 61 72 67 75 6d 65 6e 74 73 20 61 6e 64 ed arguments and
0fb0: 20 74 68 65 69 72 20 69 6e 74 65 72 70 72 65 74 their interpret
0fc0: 61 74 69 6f 6e 3a 0d 0a 3c 75 6c 3e 0d 0a 3c 6c ation:..<ul>..<l
0fd0: 69 3e 3c 62 3e 73 68 70 5f 70 61 74 68 3c 2f 62 i><b>shp_path</b
0fe0: 3e 20 28 3c 69 3e 3c 62 3e 6d 61 6e 64 61 74 6f > (<i><b>mandato
0ff0: 72 79 3c 2f 62 3e 3c 2f 69 3e 29 3a 20 74 68 65 ry</b></i>): the
1000: 20 72 65 6c 61 74 69 76 65 20 6f 72 20 61 62 73 relative or abs
1010: 6f 6c 75 74 65 20 70 61 74 68 6e 61 6d 65 20 6c olute pathname l
1020: 65 61 64 69 6e 67 20 74 6f 20 74 68 65 20 65 78 eading to the ex
1030: 74 65 72 6e 61 6c 65 20 44 42 46 20 66 69 6c 65 ternale DBF file
1040: 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e ...<ul>..<li><b>
1050: 4e 6f 74 65 3c 2f 62 3e 3a 20 74 68 65 20 66 75 Note</b>: the fu
1060: 6c 6c 20 70 61 74 68 20 6d 75 73 74 20 62 65 20 ll path must be
1070: 70 61 73 73 65 64 2c 20 69 6e 63 6c 75 64 69 6e passed, includin
1080: 67 20 74 68 65 20 66 69 6e 61 6c 20 3c 69 3e 2a g the final <i>*
1090: 2e 64 62 66 3c 2f 69 3e 20 73 75 66 66 69 78 2e .dbf</i> suffix.
10a0: 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 </li>..</ul></li
10b0: 3e 0d 0a 3c 6c 69 3e 3c 62 3e 63 68 61 72 73 65 >..<li><b>charse
10c0: 74 5f 65 6e 63 6f 64 69 6e 67 3c 2f 62 3e 20 28 t_encoding</b> (
10d0: 3c 69 3e 3c 62 3e 6d 61 6e 64 61 74 6f 72 79 3c <i><b>mandatory<
10e0: 2f 62 3e 3c 2f 69 3e 29 3a 20 63 61 6e 6f 6e 69 /b></i>): canoni
10f0: 63 61 6c 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 cal name of the
1100: 63 68 61 72 73 65 74 20 65 6e 63 6f 64 69 6e 67 charset encoding
1110: 20 61 64 6f 70 74 65 64 20 62 79 20 74 68 65 20 adopted by the
1120: 3c 62 3e 44 42 46 3c 2f 62 3e 20 6d 65 6d 62 65 <b>DBF</b> membe
1130: 72 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 45 78 r...<ul>..<li>Ex
1140: 61 6d 70 6c 65 73 20 6f 66 20 76 61 6c 69 64 20 amples of valid
1150: 6e 61 6d 65 73 20 61 72 65 3a 20 3c 62 3e 41 53 names are: <b>AS
1160: 43 49 49 3c 2f 62 3e 2c 20 3c 62 3e 55 54 46 2d CII</b>, <b>UTF-
1170: 38 3c 2f 62 3e 2c 20 3c 62 3e 43 50 38 35 30 3c 8</b>, <b>CP850<
1180: 2f 62 3e 2c 20 3c 62 3e 49 53 4f 2d 38 38 34 39 /b>, <b>ISO-8849
1190: 2d 31 3c 2f 62 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 -1</b></li>..<li
11a0: 3e 59 6f 75 20 63 61 6e 20 63 68 65 63 6b 20 74 >You can check t
11b0: 68 65 20 66 75 6c 6c 20 6c 69 73 74 20 6f 66 20 he full list of
11c0: 73 75 70 70 6f 72 74 65 64 20 63 68 61 72 73 65 supported charse
11d0: 74 20 65 6e 63 6f 64 69 6e 67 73 20 66 72 6f 6d t encodings from
11e0: 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 73 3a <a href="https:
11f0: 2f 2f 77 77 77 2e 67 6e 75 2e 6f 72 67 2f 73 6f //www.gnu.org/so
1200: 66 74 77 61 72 65 2f 6c 69 62 69 63 6f 6e 76 2f ftware/libiconv/
1210: 22 3e 68 65 72 65 3c 2f 61 3e 2e 3c 2f 6c 69 3e ">here</a>.</li>
1220: 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 6c ..</ul></li>..<l
1230: 69 3e 3c 62 3e 74 65 78 74 5f 64 61 74 65 73 3c i><b>text_dates<
1240: 2f 62 3e 20 28 3c 69 3e 3c 62 3e 6f 70 74 69 6f /b> (<i><b>optio
1250: 6e 61 6c 3c 2f 62 3e 3c 2f 69 3e 29 3a 20 74 68 nal</b></i>): th
1260: 69 73 20 69 73 20 61 20 3c 62 3e 42 4f 4f 4c 45 is is a <b>BOOLE
1270: 41 4e 3c 2f 62 3e 20 66 6c 61 67 3a 0d 0a 3c 75 AN</b> flag:..<u
1280: 6c 3e 0d 0a 3c 6c 69 3e 69 66 20 73 65 74 20 74 l>..<li>if set t
1290: 6f 20 3c 62 3e 30 3c 2f 62 3e 20 28 3c 62 3e 46 o <b>0</b> (<b>F
12a0: 41 4c 53 45 3c 2f 62 3e 29 20 61 6c 6c 20 66 69 ALSE</b>) all fi
12b0: 65 6c 64 73 20 6f 66 20 74 68 65 20 3c 62 3e 44 elds of the <b>D
12c0: 41 54 45 3c 2f 62 3e 20 74 79 70 65 20 77 69 6c ATE</b> type wil
12d0: 6c 20 62 65 20 72 65 70 72 65 73 65 6e 74 65 64 l be represented
12e0: 20 61 73 20 3c 61 20 68 72 65 66 3d 22 68 74 74 as <a href="htt
12f0: 70 73 3a 2f 2f 77 77 77 2e 73 71 6c 69 74 65 2e ps://www.sqlite.
1300: 6f 72 67 2f 6c 61 6e 67 5f 64 61 74 65 66 75 6e org/lang_datefun
1310: 63 2e 68 74 6d 6c 22 3e 6a 75 6c 69 61 6e 20 64 c.html">julian d
1320: 61 74 65 73 3c 2f 61 3e 3c 2f 6c 69 3e 0d 0a 3c ates</a></li>..<
1330: 6c 69 3e 69 66 20 73 65 74 20 74 6f 20 61 6e 79 li>if set to any
1340: 20 6f 74 68 65 72 20 69 6e 74 65 67 65 72 20 76 other integer v
1350: 61 6c 75 65 20 28 3c 62 3e 54 52 55 45 3c 2f 62 alue (<b>TRUE</b
1360: 3e 29 20 61 6c 6c 20 66 69 65 6c 64 73 20 6f 66 >) all fields of
1370: 20 74 68 65 20 3c 62 3e 44 41 54 45 3c 2f 62 3e the <b>DATE</b>
1380: 20 74 79 70 65 20 77 69 6c 6c 20 62 65 20 72 65 type will be re
1390: 70 72 65 73 65 6e 74 65 64 20 61 73 20 54 65 78 presented as Tex
13a0: 74 20 53 74 72 69 6e 67 73 20 61 73 20 65 2e 67 t Strings as e.g
13b0: 2e 20 3c 62 3e 32 30 31 38 2d 30 38 2d 32 31 3c . <b>2018-08-21<
13c0: 2f 62 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 69 66 /b></li>..<li>if
13d0: 20 6e 6f 74 20 65 78 70 6c 69 63 69 74 6c 79 20 not explicitly
13e0: 73 70 65 63 69 66 69 65 64 2c 20 3c 62 3e 54 52 specified, <b>TR
13f0: 55 45 3c 2f 62 3e 20 77 69 6c 6c 20 62 65 20 61 UE</b> will be a
1400: 6c 77 61 79 73 20 61 73 73 75 6d 65 64 20 28 64 lways assumed (d
1410: 65 66 61 75 6c 74 20 73 65 74 74 69 6e 67 29 2e efault setting).
1420: 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 </li>..</ul></li
1430: 3e 0d 0a 3c 6c 69 3e 3c 62 3e 63 6f 6c 6e 61 6d >..<li><b>colnam
1440: 65 5f 63 61 73 65 3c 2f 62 3e 20 28 3c 69 3e 3c e_case</b> (<i><
1450: 62 3e 6f 70 74 69 6f 6e 61 6c 3c 2f 62 3e 3c 2f b>optional</b></
1460: 69 3e 29 3a 20 74 68 69 73 20 61 72 67 75 6d 65 i>): this argume
1470: 6e 74 20 73 70 65 63 69 66 69 65 73 20 69 66 20 nt specifies if
1480: 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 73 all column names
1490: 20 73 68 6f 75 6c 64 20 62 65 20 75 70 70 65 72 should be upper
14a0: 63 61 73 65 20 6f 72 20 6c 6f 77 65 72 63 61 73 case or lowercas
14b0: 65 2e 3c 62 72 3e 0d 0a 56 61 6c 69 64 20 73 65 e.<br>..Valid se
14c0: 74 74 69 6e 67 73 20 61 72 65 3a 0d 0a 3c 75 6c ttings are:..<ul
14d0: 3e 0d 0a 3c 6c 69 3e 3c 62 3e 75 70 70 65 72 63 >..<li><b>upperc
14e0: 61 73 65 3c 2f 62 3e 20 6f 72 20 3c 62 3e 75 70 ase</b> or <b>up
14f0: 70 65 72 3c 2f 62 3e 3a 20 61 6c 6c 20 63 6f 6c per</b>: all col
1500: 75 6d 6e 20 6e 61 6d 65 73 20 77 69 6c 6c 20 62 umn names will b
1510: 65 20 66 75 6c 6c 79 20 63 61 70 69 74 61 6c 69 e fully capitali
1520: 7a 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c zed.</li>..<li><
1530: 62 3e 6c 6f 77 65 72 63 61 73 65 3c 2f 62 3e 20 b>lowercase</b>
1540: 6f 72 20 3c 62 3e 6c 6f 77 65 72 3c 2f 62 3e 3a or <b>lower</b>:
1550: 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 all column name
1560: 73 20 77 69 6c 6c 20 62 65 20 66 75 6c 6c 20 6c s will be full l
1570: 6f 77 65 72 63 61 73 65 2e 3c 2f 6c 69 3e 0d 0a owercase.</li>..
1580: 3c 6c 69 3e 3c 62 3e 73 61 6d 65 63 61 73 65 3c <li><b>samecase<
1590: 2f 62 3e 20 6f 72 20 3c 62 3e 73 61 6d 65 3c 2f /b> or <b>same</
15a0: 62 3e 3a 20 61 6c 6c 20 63 6f 6c 75 6d 6e 20 6e b>: all column n
15b0: 61 6d 65 73 20 77 69 6c 6c 20 62 65 20 65 78 61 ames will be exa
15c0: 63 74 6c 79 20 70 72 65 73 65 72 76 65 64 20 61 ctly preserved a
15d0: 73 20 74 68 65 79 20 61 72 65 20 64 65 66 69 6e s they are defin
15e0: 65 64 20 69 6e 74 6f 20 74 68 65 20 44 42 46 20 ed into the DBF
15f0: 6d 65 6d 65 62 65 72 2e 3c 2f 6c 69 3e 0d 0a 3c memeber.</li>..<
1600: 6c 69 3e 69 66 20 6e 6f 74 20 73 70 65 63 69 66 li>if not specif
1610: 69 65 64 2c 20 6f 72 20 69 66 20 61 6e 79 20 6f ied, or if any o
1620: 74 68 65 72 20 64 65 66 69 6e 69 74 69 6f 6e 20 ther definition
1630: 64 65 66 69 6e 69 74 69 6f 6e 20 69 73 20 66 6f definition is fo
1640: 75 6e 64 2c 20 3c 62 3e 75 70 70 65 72 63 61 73 und, <b>uppercas
1650: 65 3c 2f 62 3e 20 77 69 6c 6c 20 62 65 20 61 6c e</b> will be al
1660: 77 61 79 73 20 61 73 73 75 6d 65 64 20 28 64 65 ways assumed (de
1670: 66 61 75 6c 74 20 73 65 74 74 69 6e 67 29 2e 3c fault setting).<
1680: 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 3e /li>..</ul></li>
1690: 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 74 61 ..</ul><br>..<ta
16a0: 62 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 23 66 66 ble bgcolor="#ff
16b0: 66 66 61 30 22 20 63 65 6c 6c 70 61 64 64 69 6e ffa0" cellpaddin
16c0: 67 3d 22 31 30 22 3e 3c 74 72 3e 3c 74 64 3e 0d g="10"><tr><td>.
16d0: 0a 3c 62 3e 4e 6f 74 65 3c 2f 62 3e 3a 20 71 75 .<b>Note</b>: qu
16e0: 6f 74 69 6e 67 20 6f 72 20 6e 6f 74 20 61 6e 79 oting or not any
16f0: 20 54 65 78 74 20 53 74 72 69 6e 67 20 77 68 65 Text String whe
1700: 6e 20 69 74 20 61 70 70 65 61 72 73 20 61 73 20 n it appears as
1710: 61 20 56 69 72 74 75 61 6c 20 54 61 62 6c 65 20 a Virtual Table
1720: 61 72 67 75 6d 65 6e 74 20 68 61 73 20 61 62 73 argument has abs
1730: 6f 6c 75 74 65 6c 79 20 6e 6f 20 65 66 66 65 63 olutely no effec
1740: 74 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a t...<verbatim>..
1750: 53 45 4c 45 43 54 20 43 52 45 41 54 45 20 56 49 SELECT CREATE VI
1760: 52 54 55 41 4c 20 54 41 42 4c 45 20 6d 79 5f 74 RTUAL TABLE my_t
1770: 61 62 6c 65 20 55 53 49 4e 47 20 56 69 72 74 75 able USING Virtu
1780: 61 6c 44 62 66 28 20 2f 68 6f 6d 65 2f 73 61 6e alDbf( /home/san
1790: 64 72 6f 2f 6d 79 73 68 70 20 2c 20 43 50 31 32 dro/myshp , CP12
17a0: 35 32 20 2c 20 31 20 2c 20 6c 6f 77 65 72 20 29 52 , 1 , lower )
17b0: 3b 0d 0a 6f 72 0d 0a 53 45 4c 45 43 54 20 43 52 ;..or..SELECT CR
17c0: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
17d0: 4c 45 20 6d 79 5f 74 61 62 6c 65 20 55 53 49 4e LE my_table USIN
17e0: 47 20 56 69 72 74 75 61 6c 44 62 66 28 20 27 2f G VirtualDbf( '/
17f0: 68 6f 6d 65 2f 73 61 6e 64 72 6f 2f 6d 79 73 68 home/sandro/mysh
1800: 70 27 20 2c 20 27 43 50 31 32 35 32 27 20 2c 20 p' , 'CP1252' ,
1810: 31 20 2c 20 27 6c 6f 77 65 72 27 20 29 3b 0d 0a 1 , 'lower' );..
1820: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 42 6f 74 </verbatim>..Bot
1830: 68 20 6e 6f 74 61 74 69 6f 6e 73 20 77 69 6c 6c h notations will
1840: 20 70 72 6f 64 75 63 65 20 65 78 61 63 74 6c 79 produce exactly
1850: 20 74 68 65 20 73 61 6d 65 20 69 64 65 6e 74 69 the same identi
1860: 63 61 6c 20 72 65 73 75 6c 74 2e 0d 0a 3c 2f 74 cal result...</t
1870: 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 0d d></tr></table>.
1880: 0a 0d 0a 3c 61 20 68 72 65 66 3d 22 68 74 74 70 ...<a href="http
1890: 73 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 s://www.gaia-gis
18a0: 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c 69 62 73 70 .it/fossil/libsp
18b0: 61 74 69 61 6c 69 74 65 2f 68 6f 6d 65 22 3e 62 atialite/home">b
18c0: 61 63 6b 20 74 6f 20 6d 61 69 6e 20 70 61 67 65 ack to main page
18d0: 3c 2f 61 3e 0a 5a 20 66 33 31 35 38 32 35 38 34 </a>.Z f31582584
18e0: 38 63 65 31 39 30 33 31 61 66 35 36 66 30 38 65 8ce19031af56f08e
18f0: 39 36 61 61 34 34 34 0a 96aa444.