If you need to directly operate the database, creating a spatial database using SQL scripts requires attention. After creating the database, it is also necessary to write some essential metadata information into the corresponding tables. Then, insert row data (one row represents one map element) into the spatial table. You can refer to the following SQL statements for operation, and it will definitely succeed.
1. Create the spatial table:
```sql
CREATE TABLE Spatable (
ID NUMBER(11),
NAME VARCHAR2(32),
MI_STYLE VARCHAR2(254),
MI_PRINX NUMBER(11),
GEOLOC MDSYS.SDO_GEOMETRY
);
```
2. Insert table element information into the MapCatalog table. If this table does not exist, please log in to the database with mapinfo/mapinfo credentials and import the script provided by MapInfo. This script can be found in the directory after installing MapXtreme for Java.
```sql
INSERT INTO mapinfo.mapinfo_mapcatalog (
spatialtype, tablename, ownername, spatialcolumn, db_x_ll, db_y_ll,
db_x_ur, db_y_ur, coordinatesystem, symbol, xcolumnname, ycolumnname,
renditiontype, renditioncolumn, renditiontable, number_rows
)
VALUES (
13, 'SPATABLE', 'DEMOGIS', 'GEOLOC', 0, 100000, 0, 100000,
'NONEARTH UNITS "M" BOUNDS (0, 0) (100000, 100000)', NULL,
'NO_COLUMN', 'NO_COLUMN', 1, 'MI_STYLE', NULL, NULL
);
```
3. Insert table element information into the MapCatalog table, which comes pre-installed with Oracle Spatial:
```sql
INSERT INTO USER_SDO_GEOM_METADATA VALUES (
'Spatable', 'GEOLOC', MDSYS.SDO_DIM_ARRAY(
MDSYS.SDO_DIM_ELEMENT('x', 0, 10000, .000000001),
MDSYS.SDO_DIM_ELEMENT('Y', 0, 10000, .000000001)
), NULL
);
```
4. Create a spatial index:
```sql
CREATE INDEX Spatable_SX ON Spatable(GEOLOC) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
```
5. Create an index:
```sql
CREATE INDEX Spatable_idx ON Spatable(mi_prinx);
```
6. Insert data into the table, where one row represents one element:
```sql
INSERT INTO Spatable VALUES (
1, 'tab_1', '', 1,
MDSYS.SDO_GEOMETRY(
2001, NULL, MDSYS.SDO_POINT_TYPE(6027.08803, 1563.71732, NULL), NULL, NULL
)
);
```
Article source: [Eden Network](http://www.edenw.com/tech/devdeloper/database/2010-07-18/4788.html)