Purpose
Creates a new table. You can issue this statement from the MapBasic window in MapInfo Pro.
Syntax
Create Table table_name
[ ( column columntype [ , ... ] ) | Using from_table ]
[ File filespec ]
[ {
Type { NATIVE [ Charset char_set ] [ Version version_pro ] [ Hide ] |
NATIVEX [ Charset char_set ] [ Locale locale ] [ Hide ] } |
Type DBF [ CharSet char_set ] [ Version version_pro ] |
Type { Access | ODBC }
Database database_filespec [ Version version_msaccess ]
Table db_table_name [ Password pwd ] [ CharSet char_set ]
[ Version version_pro ] |
Type TILESERVER
TileType { LevelRowColumn | QuadKey }
URL url
[ AttributionText "attributiontext" ] [ Font font_clause ]
[ StartTileNum { 0 | 1 } ]
[ Minlevel min_level ]
MaxLevel max_level
[ Origin { "SW" | "NW" } ]
Height tile_height [Width tile_width]
[ ReadTimeout read_time_out ]
[ RequestTimeout request_time_out]
CoordSys coordsys
Type TILESERVER
TileType { WMTS }
URL url
Layer layer
TileMatrixSet tileMatrixSet
Style style
Format imageFormat
[ Override Coordinate Order { On | Off } ]
[ ReadTimeout read_time_out]
[ RequestTimeout request_time_out]
[ CoordSys coordsys ]
[ PassThrough "name1" "Value1", "name2" "Value2", ... ]
} ]
table_name is the name of the table as you want it to appear in MapInfo Pro.
column is the name of a column to create. Column names can be up to 31 characters long, and can contain letters, numbers, and the underscore (_) character. Column names cannot begin with numbers.
columntype is the data type associated with the column. Each columntype is defined as follows:
Char( width ) | Float | Integer | SmallInt |
Decimal( width, decplaces ) | Date | DateTime | Time | Logical
Where Decimal width is from 1 to 20, and Decimal decplaces from 0 to 16. The decplaces setting must either be zero (0) or 2 less than width; if width is 10, decplaces can be up to 8.
from_table is the name of a currently open table in which the column you want to place in a new table is stored. The from_table must be a base table, and must contain column data. Query tables and raster tables cannot be used and will produce an error. The column structure of the new table will be identical to this table.
filespec specifies where to create the .TAB, .MAP, and .ID files (and in the case of Access, .AID files). If you omit the File clause, files are created in the current directory.
version_pro is 100 (to create a table that can be read by versions of MapInfo Pro), or 300 for (MapInfo Pro 3.0 format). Does not apply when creating an Access table; the version of the Access table is handled by DAO.
Type DBF:
char_set is the name of a character set; see CharSet clause.
Type { Access | ODBC }:
database_filespec is a string that identifies a valid Access database. If the specified database does not exist, MapInfo Pro creates a new Access (.MDB or .ACCDB) file.
version_msaccess is an expression that specifies the version of the Microsoft Jet database format to be used by the new database. Acceptable values are 4.0 (for Access 2000) or 3.0 (for Access '95/'97). If omitted, the default version is 23.0.0. If the database in which the table is being created already exists, the specified database version is ignored.
db_table_name is a string that indicates the name of the table as it will appear in Access.
pwd is the database-level password for the database, to be specified when database security is turned on.
char_set is the name of a character set; see CharSet clause.
Type TILESERVER:
url is the fully qualified URL, either http://<server> or https://<server>, to request a tile from a tile server. If the URL does not have the following replaceable tags, then the Create Table fails:
- If tile_type is QuadKey, then the URL must contain {QUADKEY}.
- If tile_type is LevelRowColumn, then the URL must contain {LEVEL}, {ROW}, and {COL} tags that will be replaced at runtime. Servers support the {ROW} and {COL} tags differently; sometimes these tags may need to be reversed for row and column (or X, Y).
- If tile_type is WMTS, then the URL must contain {TileMatrix}, {TileRow}, and {TileCol} tags.
attributiontext is the attribution text that will display as text in the map window when displaying tiles from a tileserver. This text must be in quotes ("...").
font_clause is optional and specifies the font style to use on the attribution text. This is a Font expression, for example, MakeFont( fontname, style, size, fgcolor, bgcolor ).
Font ("Verdana", 1, 24, 0, 255)
Font MakeFont("Verdana", 1, 24, 0, 255)
For more details, see Font clause or MakeFont() function.
min_level is the minimum level for a tile server. This must be either zero (0) or a positive value and less than the max_level. The default is zero (0).
max_level is the max level the tile server supports. This must be a positive value.
tile_height is the height in pixels of a single tile from the tile server. This must be a positive value.
tile_width is the width in pixels of a single tile from the tile server. If specified, this must be a positive value. If not specified, the height is used as the width.
layer is the identifier for the WMTS layer to be displayed.
tileMatrixSet is the identifier for a tile matrix set in the WMTS layer.
style is the style for the layer to be selected among the styles supported by the WMTS layer.
imageFormat is the image format for the tiles, to be selected among the image formats supported by the WMTS layer.
read_time_out is the number in seconds until the read of tiles times out (the default is 300). This must be a positive value.
request_time_out is a value in seconds until the request of the tiles times out (the default is 100). This must be a positive value.
coordsys is the default coordinate system for the tile server. MapInfo Pro cannot reproject the tile server image, so it reprojects the map to use this coordinate system. You are unable to change the coordinate system for the map when it includes a tile server layer. The bounds of the coordinate system also specify the bounds of the first tile (the one tile in the minimum level). This is how MapInfo Pro knows how to calculate the extent of the tiles in the other levels.
The optional Hide keyword is used to create a table which does not appear in the Table List user interface. The TableInfo() attribute TAB_INFO_ISHIDDEN will return True.
Description
The Create Table statement creates a new empty table with up to 250 columns. Specify ODBC to create new tables on a DBMS server.
The Using clause allows you to create a new table as part of the "Combine Objects Using Column" functionality. The from_table must be a base table, and must contain column data. Query tables and raster tables cannot be used and will produce an error. The column structure of the new table being created will be identical to this table.
The optional File clause specifies where to create the new table. If no File clause is used, the table is created in the current directory or folder.
The optional Type clause specifies the table's data format. The default type is NATIVE, but can alternately be DBF. The NATIVE format takes up less disk space than the DBF format, but the DBF format produces base files that can be read in any dBASE-compatible database manager. Also, create new tables on DBMS Servers from the ODBC Type clause in the Create Table statement. The NATIVEX clause specifies a MapInfo Extended TAB file, which supports Unicode character sets, such as UTF-8 and UTF-16.
The Locale clause is set with the NATIVEX clause to specify the locale of the index to create, which will affect the sorting behavior of the table. It takes a string value, such as "en-US". If not specified, default system locale is used. This clause only applies to NativeX (MapInfo Extended TAB) tables with a character set (charset) of UTF-8 or UTF-16.
The CharSet clause specifies a character set. The char_set parameter should be a string constant, such as "WindowsLatin1". If no CharSet clause is specified, MapBasic uses the default character set for the hardware platform that is in use at runtime. For more details, see CharSet clause.
The SmallInt column type reserves two bytes for each value; thus, the column can contain values from -32,767 to +32,767. The Integer column type reserves four bytes for each value; thus, the column can contain values from -2,147,483,647 to +2,147,483,647.
The TileType clause specifies the type of the tile server this table will use, QuadKey, or LevelRowColumn, or WMTS. This represents the way that the tile server retrieves the tiles. You must set this based on what the server supports and uses:
QuadKey - A server that uses a quad tree algorithm splits the world up into squares that are 256 pixels by 256 pixels. Each tile is referred to by a unique string of characters between 0 - 3 (QuadKey), which describes the position and zoom level at which to place the tile.
LevelRowColumn - A server that splits the world up into squares where each tile identifier is a list containing the zoom level, row, and column number of the tile. The format of the tile identifier may vary from server to server, so the {ROW} and {COL} tags may seem reversed for some servers.
WMTS - A server that implements standards published by OGC for Web Map Tile Service.
The StartTileNum clause is optional. It is the number of the starting tile, either zero (0) or one (1). Zero (0) is the default start tile number.
The Origin clause is optional for tables of type TileServer. If this clause is present, you must include one of the two values - "NW" or "SW". "SW" represents a South-West origin in which the tiles in the TileServer table are arranged in a bottom-up manner, starting from the lower-left corner. "NW" represents a North-West origin of the tiles, starting from the upper-left corner. If no value is included, "NW" is used by default.
The Override Coordinate Order is an optional clause that is applied when the coordinate order is incorrect for a tile matrix set on a WMTS server.
PassThrough is an optional clause that is a set of name / value pairs that are sent to the WMTS server. These can be used for the custom parameters supported by the server, like additional dimensions. You can enter multiple name / value pairs in this clause.
The Version clause controls the table's format. If you specify Version 100, MapInfo Pro creates a table in a format that can be read by versions of MapInfo Pro. If you specify Version 300, MapInfo Pro creates a table in the format used by MapInfo Pro 3.0. Note that region and polyline objects having more than 8,000 nodes and multiple-segment polyline objects require version 300. If you omit the Version clause, the table is created in the version 300 format.
Messages when creating a Tile Server Table
If an error occurs while fetching tiles from the server, which can happen when drawing a tile server layer in a map window, then check:
- The tile server URL is incorrect.
- The tile server is currently available.
- The amount of time the server takes to respond to the request does not exceed the specified timeout value.
- Improper authentication due to the tile server being on a secure server or is accessed through a proxy server.
If an error occurs loading a tile server table, then check if:
- A required property in the configuration file is missing.
- The configuration file is missing.
If an error occurs creating the tile server configuration file, which is an XML file, then check that the configuration file can be created in the path supplied.
Example
The following example shows how to create a table for a TMS tile server with a South-West origin.
Dim sPath As String
sPath="D:\MapInfo\Tables\TMS.tab"
Create Table PathToTableName$(sPath)
File sPath
Type TILESERVER
TileType "LevelRowColumn"
URL "http://INSERT_TILE_SERVER_NAME/{LEVEL}/{ROW}/{COL}.png"
AttributionText "required attribution text" Font ("Arial",256,10,0,16777215)
MinLevel 0
MaxLevel 15
Height 256
CoordSys Earth Projection 20, 109, 7, 5.387638889, 52.156160556, 0.9999079, 155000, 463000 Bounds (-285401.92, 22598.08) (595401.92, 903401.92)
Origin "SW"
The following example shows how to create a table called Towns, containing 3 fields: a character field called townname, an integer field called population, and a decimal field called median_income. The file will be created in the subdirectory C:\MAPINFO\DATA. Since an optional Type clause is used, the table will be built around a dBASE file.
Create Table Towns
( townname Char(30),
population SmallInt,
median_income Decimal(9,2) )
File "C:\MAPINFO\TEMP\TOWNS"
Type DBF
The following example creates a native MapInfo table (TAB file) named test in the "WindowsGreek" character set.
Create Table "test" (Field1 Char(10)) file "test.TAB" TYPE NATIVE Charset "WindowsGreek"
The following example creates a MapInfo Extended table (TAB file) in the UTF-16 character set and U.S. English locale ("en-US").
Create Table "pangramsNativeX_utf_16" (fid LargeInt,language Char(254),textval Char(254),number_of_utf16_chars LargeInt,number_of_utf8_chars LargeInt) file "pangramsNativeX_utf-16.TAB" TYPE NATIVEX Charset "UTF-16" Locale "en-US"
Examples for TILESERVER
The following examples show how to create tile server tables for various tile servers. In the examples, the table name and file name are determined by the users. The attribution text should be the attribution legally required by the provider of the server.
The following example shows how to create a tile server table which uses a MapInfo Developer tile server:
Create Table MIDev_TileServer
File "MIDev_TileServer"
Type TILESERVER
TileType "LevelRowColumn"
URL
"http://INSERT_SERVER_NAME_HERE/MapTilingService/MapName/{LEVEL}/{ROW}
:{COL}/tile.gif"
AttributionText "required attribution text"
Font("Verdena",255,16,0,255)
StartTileNum 1
MaxLevel 20
Height 256
CoordSys Earth Projection 10, 157, 7, 0 Bounds(-20037508.34,-
20037508.34) (20037508.34,20037508.34)
The following example shows how to create a tile server table which uses a MapXtreme.NET tile server:
Create Table MXT_TileServer
File "MXT_TileServer"
Type TILESERVER
TileType "LevelRowColumn"
URL
"http://INSERT_SERVER_NAME_HERE/TileServer/MapName/{LEVEL}/{ROW};{COL}
/tile.png"
AttributionText "required attribution text"
Font("Calibri",255,16,0,255)
MaxLevel 20
Height 256
RequestTimeout 90
ReadTimeout 60
CoordSys Earth Projection 10, 157, 7, 0 Bounds(-20037508.34,-
20037508.34) (20037508.34,20037508.34)
The following example shows how to create a tile server table which uses an OpenStreetMap tile server:
Create Table OSM_TileServer
File "OSM_TileServer"
Type TILESERVER
TileType "LevelRowColumn"
URL
"http://INSERT_OPEN_STREET_MAP_SERVER_NAME_HERE/{LEVEL}/{ROW}/{COL}.pn
g"
AttributionText "required attribution text" Font("Arial",255,16,0,255)
MinLevel 0
MaxLevel 15
Height 256
CoordSys Earth Projection 10, 157, 7, 0 Bounds(-20037508.34,-
20037508.34) (20037508.34,20037508.34)
The following example shows how create a tile server table which uses a WMTS tile server.
Create Table WMTS_TileServer
File "WMTS_TileServer"
Type TILESERVER
TileType "WMTS"
URL "http://ENTER_CAPABILITIES_URL_HERE"
Layer "layer_id"
TileMatrixSet "tileMatrixSet_id"
Style "style_name"
Format "image/png"
RequestTimeout 90
ReadTimeout 60
CoordSys Earth Projection 10, 157, 7, 0 Bounds(-20037508.34,-
20037508.34) (20037508.34,20037508.34)
See Also:
Alter Table statement, Create Index statement, Create Map statement, Drop Table statement, Export statement, Import statement, Open Table statement