Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java	(revision 43649)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java	(revision 43650)
@@ -217,7 +217,9 @@
         public TableNameBuilder table();
         public AlterTableBuilder drop_column(String columnName);
         public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);
+        public AlterTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls);
         public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);
+        public AlterTableBuilder alter_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls);
         public AlterTableBuilder rename_column(String source, String target);
         public List<String> toStrings();
     }
@@ -262,8 +264,11 @@
     
     public boolean supportSchemas();
 
+    @Deprecated
     public String sqltype(int dataType, int p, int s);
     
+    public String sqltype(int dataType, int p, int s, int geomType, int geomSubtype);
+    
     public Object sqlgeometrytype(int type, int subtype);
 
     public Object sqlgeometrydimension(int type, int subtype);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java	(revision 43649)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java	(revision 43650)
@@ -1198,7 +1198,7 @@
         protected List<String> drops;
         protected List<ColumnDescriptorBuilderBase> adds;
         protected List<ColumnDescriptorBuilderBase> alters;
-        protected List<Pair> renames;
+        protected List<Pair<String,String>> renames;
 
         public AlterTableBuilderBase() {
             this.drops = new ArrayList<>();
@@ -1241,6 +1241,15 @@
         }
 
         @Override
+        public AlterTableBuilder add_geometry_column(String columnName, int type, int subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
+            if( StringUtils.isEmpty(columnName) ) {
+                throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
+            }
+            this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
+            return this;
+        }
+
+        @Override
         public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
             if (isPk || isAutomatic) {
                 allowNulls = false;
@@ -1250,6 +1259,15 @@
         }
 
         @Override
+        public AlterTableBuilder alter_geometry_column(String columnName, int type, int subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
+            if( StringUtils.isEmpty(columnName) ) {
+                throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
+            }
+            this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
+            return this;
+        }
+
+        @Override
         public AlterTableBuilder rename_column(String source, String target) {
             this.renames.add(new ImmutablePair(source, target));
             return this;
@@ -1330,30 +1348,21 @@
              [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
 
              */
-            StringBuilder builder = new StringBuilder();
 
-            builder.append("ALTER TABLE");
-            builder.append(this.table.toString());
-            builder.append(" ");
-            boolean first = true;
             for (String column : drops) {
-                if (first) {
-                    first = false;
-                } else {
-                    builder.append(", ");
-                }
-                builder.append("DROP COLUMN IF EXISTS ");
-                builder.append(column);
+                StringBuilder builder = new StringBuilder();
+                builder.append("ALTER TABLE ");
+                builder.append(this.table.toString());
+                builder.append(" DROP COLUMN IF EXISTS ");
+                builder.append(identifier(column)); 
+                sqls.add(builder.toString());
             }
-            first = drops.isEmpty();
             for (ColumnDescriptorBuilderBase column : adds) {
-                if (first) {
-                    first = false;
-                } else {
-                    builder.append(", ");
-                }
-                builder.append("ADD COLUMN ");
-                builder.append(column.getName());
+                StringBuilder builder = new StringBuilder();
+                builder.append("ALTER TABLE ");
+                builder.append(this.table.toString());
+                builder.append(" ADD COLUMN ");
+                builder.append(identifier(column.getName())); 
                 builder.append(" ");
                 if( column.getType() == DataTypes.INT && column.isAutomatic() ) {
                     builder.append(" SERIAL");
@@ -1377,55 +1386,83 @@
                 if (column.isPrimaryKey()) {
                     builder.append(" PRIMARY KEY");
                 }
+                sqls.add(builder.toString());
+                if( column.isIndexed() ) {
+                    String sql;
+                    String name = "idx_" + this.table().getName() + "_" + column.getName();
+                    if( column.isGeometry() ) {
+                        sql = MessageFormat.format(
+                            config.getString(SQLConfig.CREATE_INDEX_name_ON_table_USING_GIST_column),
+                            name,
+                            this.table().toString(),
+                            column.getName()
+                        );
+                    } else {
+                        sql = MessageFormat.format(
+                            config.getString(SQLConfig.CREATE_INDEX_name_ON_table_column),
+                            name,
+                            this.table().toString(),
+                            column.getName()
+                        );
+                    }
+                    sqls.add(sql);
+                }
             }
-            first = drops.isEmpty() && adds.isEmpty();
             for (ColumnDescriptorBuilderBase column : alters) {
-                if (first) {
-                    first = false;
-                } else {
-                    builder.append(", ");
-                }
-                builder.append("ALTER COLUMN ");
-                builder.append(column.getName());
-                builder.append("SET DATA TYPE ");
+                StringBuilder builder = new StringBuilder();
+                builder.append("ALTER TABLE ");
+                builder.append(this.table.toString());
+                builder.append(" ALTER COLUMN ");
+                builder.append(identifier(column.getName())); 
+                builder.append(" SET DATA TYPE ");
                 if( column.getType() == DataTypes.INT && column.isAutomatic() ) {
                     builder.append(" SERIAL");
                 } else {
                     builder.append(sqltype(column.getType(), column.getPrecision(), column.getSize()));
                 }
-                builder.append(", ");
                 if (column.getDefaultValue() == null) {
                     if (column.allowNulls()) {
-                        builder.append("ALTER COLUMN ");
-                        builder.append(column.getName());
-                        builder.append(" SET DEFAULT NULL");
+                        builder.append(" DEFAULT NULL");
                     } else {
-                        builder.append("ALTER COLUMN ");
-                        builder.append(column.getName());
                         builder.append(" DROP DEFAULT");
                     }
                 } else {
-                    builder.append("ALTER COLUMN ");
-                    builder.append(column.getName());
-                    builder.append(" SET DEFAULT '");
+                    builder.append(" DEFAULT '");
                     builder.append(column.getDefaultValue().toString());
                     builder.append("'");
                 }
+                sqls.add(builder.toString());
+                if( column.isIndexed() ) {
+                    String sql;
+                    String name = "idx_" + this.table().getName() + "_" + column.getName();
+                    if( column.isGeometry() ) {
+                        sql = MessageFormat.format(
+                            config.getString(SQLConfig.CREATE_INDEX_name_ON_table_USING_GIST_column),
+                            name,
+                            this.table().toString(),
+                            column.getName()
+                        );
+                    } else {
+                        sql = MessageFormat.format(
+                            config.getString(SQLConfig.CREATE_INDEX_name_ON_table_column),
+                            name,
+                            this.table().toString(),
+                            column.getName()
+                        );
+                    }
+                    sqls.add(sql);
+                }
             }
-            first = drops.isEmpty() && adds.isEmpty() && alters.isEmpty();
-            for (Pair pair : renames) {
-                if (first) {
-                    first = false;
-                } else {
-                    builder.append(", ");
-                }
-                builder.append("RENAME COLUMN ");
-                builder.append(pair.getLeft());
+            for (Pair<String,String> pair : renames) {
+                StringBuilder builder = new StringBuilder();
+                builder.append("ALTER TABLE ");
+                builder.append(this.table.toString());
+                builder.append(" RENAME COLUMN ");
+                builder.append(identifier(pair.getLeft())); 
                 builder.append(" TO ");
-                builder.append(pair.getRight());
+                builder.append(identifier(pair.getRight())); 
+                sqls.add(builder.toString());
             }
-            sqls.add(builder.toString());
-
             return sqls;
         }
 
@@ -1845,7 +1882,13 @@
     }
     
     @Override
+    @Deprecated
     public String sqltype(int type, int p, int s) {
+        return this.sqltype(type, p, s, Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.UNKNOWN);
+    }
+
+    @Override
+    public String sqltype(int type, int p, int s, int geomType, int geomSubtype) {
         switch (type) {
             case DataTypes.BOOLEAN:
                 return config.getString(SQLConfig.type_boolean);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/JDBCUtils.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/JDBCUtils.java	(revision 43649)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/JDBCUtils.java	(revision 43650)
@@ -33,6 +33,12 @@
         st.execute(sql);
     }
 
+    public static void execute(Connection connection, String sql) throws SQLException {
+        logger.debug("execute SQL: " + sql);
+        Statement st = connection.createStatement();
+        st.execute(sql);
+    }
+
     public static ResultSet executeQuery(PreparedStatement st, String sql) throws SQLException {
         logger.debug("execute query SQL: " + sql);
         ResultSet rs = st.executeQuery();
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java	(revision 43649)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java	(revision 43650)
@@ -5,6 +5,7 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Iterator;
+import org.apache.commons.lang3.StringUtils;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
@@ -184,7 +185,7 @@
         JDBCSQLBuilderBase sqlbuilder = buildInsertSQL(database, schema, table, type);
 
         PreparedStatement st;
-        Disposable paramsDisposer = null;
+        Disposable paramsDisposer;
         String sql = sqlbuilder.insert().toString();
         try {
             st = conn.prepareStatement(sql);
@@ -283,7 +284,7 @@
             FeatureType target
         ) {
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
-        sqlbuilder.update().table().database(database).schema(schema).name(table);
+        sqlbuilder.alter_table().table().database(database).schema(schema).name(table);
 
         for (FeatureAttributeDescriptor attrOrgiginal : original) {
             FeatureAttributeDescriptor attrTarget = target.getAttributeDescriptor(
@@ -291,37 +292,97 @@
             );
             if (attrTarget == null) {
                 sqlbuilder.alter_table().drop_column(attrOrgiginal.getName());
-            } else {
-                sqlbuilder.alter_table().alter_column(
-                        attrTarget.getName(),
-                        attrTarget.getType(),
-                        attrTarget.getPrecision(),
-                        attrTarget.getSize(),
-                        attrTarget.isPrimaryKey(),
-                        attrTarget.isIndexed(),
-                        attrTarget.allowNull(),
-                        attrTarget.isAutomatic(),
-                        attrTarget.getDefaultValue()
-                );
+            } else if( !this.areEquals(attrOrgiginal, attrTarget) ) {
+                if( attrTarget.getType()==DataTypes.GEOMETRY ) {
+                    sqlbuilder.alter_table().alter_geometry_column(
+                            attrTarget.getName(),
+                            attrTarget.getGeomType().getType(),
+                            attrTarget.getGeomType().getSubType(),
+                            attrTarget.getSRS(),
+                            attrTarget.isIndexed(),
+                            attrTarget.allowNull()
+                    );
+                } else {
+                    sqlbuilder.alter_table().alter_column(
+                            attrTarget.getName(),
+                            attrTarget.getType(),
+                            attrTarget.getPrecision(),
+                            attrTarget.getSize(),
+                            attrTarget.isPrimaryKey(),
+                            attrTarget.isIndexed(),
+                            attrTarget.allowNull(),
+                            attrTarget.isAutomatic(),
+                            attrTarget.getDefaultValue()
+                    );
+                }
             }
         }
         for (FeatureAttributeDescriptor attrTarget : target) {
             if (original.getAttributeDescriptor(attrTarget.getName()) == null) {
-                sqlbuilder.alter_table().add_column(
-                        attrTarget.getName(),
-                        attrTarget.getType(),
-                        attrTarget.getPrecision(),
-                        attrTarget.getSize(),
-                        attrTarget.isPrimaryKey(),
-                        attrTarget.isIndexed(),
-                        attrTarget.allowNull(),
-                        attrTarget.isAutomatic(),
-                        attrTarget.getDefaultValue()
-                );
+                if( attrTarget.getType()==DataTypes.GEOMETRY ) {
+                    sqlbuilder.alter_table().add_geometry_column(
+                            attrTarget.getName(),
+                            attrTarget.getGeomType().getType(),
+                            attrTarget.getGeomType().getSubType(),
+                            attrTarget.getSRS(),
+                            attrTarget.isIndexed(),
+                            attrTarget.allowNull()
+                    );
+                } else {
+                    sqlbuilder.alter_table().add_column(
+                            attrTarget.getName(),
+                            attrTarget.getType(),
+                            attrTarget.getPrecision(),
+                            attrTarget.getSize(),
+                            attrTarget.isPrimaryKey(),
+                            attrTarget.isIndexed(),
+                            attrTarget.allowNull(),
+                            attrTarget.isAutomatic(),
+                            attrTarget.getDefaultValue()
+                    );
+                }
             }
         }
         return sqlbuilder;
     }
+    
+    protected boolean areEquals(FeatureAttributeDescriptor attr1, FeatureAttributeDescriptor attr2) {
+        // No interesa si son o no iguales en general, solo si son iguales en lo 
+        // que a los atributos usados para crear la columna de la tabla se refiere.
+        if( !StringUtils.equals(attr1.getName(), attr2.getName()) ) {
+            return false;
+        }
+        if( attr1.getType() != attr2.getType() ) {
+            return false;
+        }
+        if( attr1.getPrecision() != attr2.getPrecision() ) {
+            return false;
+        }
+        if( attr1.getSize() != attr2.getSize() ) {
+            return false;
+        }
+        if( attr1.isPrimaryKey() != attr2.isPrimaryKey() ) {
+            return false;
+        }        
+        if( attr1.isIndexed() != attr2.isIndexed() ) {
+            return false;
+        }
+        if( attr1.allowNull() != attr2.allowNull() ) {
+            return false;
+        }
+        if( attr1.isAutomatic() != attr2.isAutomatic() ) {
+            return false;
+        }
+        if( attr1.getDefaultValue() != attr2.getDefaultValue() ) {
+            if( attr1.getDefaultValue()==null || attr2.getDefaultValue()==null) {
+                return false;
+            }
+            if( !attr1.getDefaultValue().equals(attr2.getDefaultValue()) ) {
+                return false;
+            }
+        }
+        return true;
+    }
 
     public void performUpdateTable(Connection conn,
             String database,
@@ -329,7 +390,6 @@
             String table,
             FeatureType original,
             FeatureType target) throws DataException {
-
         SQLBuilderBase sqlbuilder = buildUpdateTableSQL(null, null, table, original, target);
         Statement st = null;
         try {
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilder.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilder.java	(revision 43649)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilder.java	(revision 43650)
@@ -5,6 +5,7 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import org.apache.commons.lang3.tuple.Pair;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
@@ -45,8 +46,8 @@
          
 //        config.set(SQLConfig.UPDATE_TABLE_STATISTICS_table,"ANALYZE TABLE {0} SAMPLE_SIZE 0");
         config.set(SQLConfig.UPDATE_TABLE_STATISTICS_table,"ANALYZE SAMPLE_SIZE 0");
-        config.set(SQLConfig.CREATE_INDEX_name_ON_table_column, "CREATE INDEX {0} ON {1} (\"{2}\")");
-        config.set(SQLConfig.CREATE_INDEX_name_ON_table_USING_GIST_column, "CREATE INDEX {0} ON {1} (\"{2}\")");
+        config.set(SQLConfig.CREATE_INDEX_name_ON_table_column, "CREATE INDEX IF NOT EXISTS {0} ON {1} (\"{2}\")");
+        config.set(SQLConfig.CREATE_INDEX_name_ON_table_USING_GIST_column, "CREATE SPATIAL INDEX IF NOT EXISTS {0} ON {1} (\"{2}\")");
 
         config.set(SQLConfig.ST_GeomFromEWKB, "GeomFromWKB({0}, {1})");
         config.set(SQLConfig.ST_AsEWKB, "AsWKB(({0}))");        
@@ -97,6 +98,142 @@
         
     }
     
+    protected class H2SpatialAlterTableBuilderBase extends AlterTableBuilderBase {
+        @Override
+        public List<String> toStrings() {
+            List<String> sqls = new ArrayList<>();
+            for (String column : drops) {
+                StringBuilder builder = new StringBuilder();
+                builder.append("ALTER TABLE ");
+                builder.append(this.table.toString());
+                builder.append(" DROP COLUMN IF EXISTS ");
+                builder.append(identifier(column)); 
+                sqls.add(builder.toString());
+            }
+            for (ColumnDescriptorBuilderBase column : adds) {
+                StringBuilder builder = new StringBuilder();
+                builder.append("ALTER TABLE ");
+                builder.append(this.table.toString());
+                builder.append(" ADD COLUMN ");
+                builder.append(identifier(column.getName())); 
+                builder.append(" ");
+                if( column.getType() == DataTypes.INT && column.isAutomatic() ) {
+                    builder.append(" SERIAL");
+                } else {
+                    builder.append(
+                        sqltype(
+                            column.getType(), 
+                            column.getPrecision(), 
+                            column.getSize(),
+                            column.getGeometryType(), 
+                            column.getGeometrySubtype()
+                        )
+                    );
+                }
+                if (column.getDefaultValue() == null) {
+                    if (column.allowNulls()) {
+                        builder.append(" DEFAULT NULL");
+                    }
+                } else {
+                    builder.append(" DEFAULT '");
+                    builder.append(column.getDefaultValue().toString());
+                    builder.append("'");
+                }
+                if (column.allowNulls()) {
+                    builder.append(" NULL");
+                } else {
+                    builder.append(" NOT NULL");
+                }
+                if (column.isPrimaryKey()) {
+                    builder.append(" PRIMARY KEY");
+                }
+                sqls.add(builder.toString());
+                if( column.isIndexed() ) {
+                    String sql;
+                    String name = "idx_" + this.table().getName() + "_" + column.getName();
+                    if( column.isGeometry() ) {
+                        sql = MessageFormat.format(
+                            config.getString(SQLConfig.CREATE_INDEX_name_ON_table_USING_GIST_column),
+                            name,
+                            this.table().toString(),
+                            column.getName()
+                        );
+                    } else {
+                        sql = MessageFormat.format(
+                            config.getString(SQLConfig.CREATE_INDEX_name_ON_table_column),
+                            name,
+                            this.table().toString(),
+                            column.getName()
+                        );
+                    }
+                    sqls.add(sql);
+                }
+            }
+            for (ColumnDescriptorBuilderBase column : alters) {
+                StringBuilder builder = new StringBuilder();
+                builder.append("ALTER TABLE ");
+                builder.append(this.table.toString());
+                builder.append(" ALTER COLUMN ");
+                builder.append(identifier(column.getName())); 
+                builder.append(" ");
+                builder.append(
+                    sqltype(
+                        column.getType(), 
+                        column.getPrecision(), 
+                        column.getSize(),
+                        column.getGeometryType(), 
+                        column.getGeometrySubtype()
+                    )
+                );
+                if (column.getDefaultValue() == null) {
+                    if (column.allowNulls()) {
+                        builder.append(" DEFAULT NULL");
+                    }
+                } else {
+                    builder.append(" DEFAULT '");
+                    builder.append(column.getDefaultValue().toString());
+                    builder.append("'");
+                }
+                if( column.isAutomatic() ) {
+                    builder.append(" AUTO_INCREMENT");
+                }
+                sqls.add(builder.toString());
+                if( column.isIndexed() ) {
+                    String sql;
+                    String name = "idx_" + this.table().getName() + "_" + column.getName();
+                    if( column.isGeometry() ) {
+                        sql = MessageFormat.format(
+                            config.getString(SQLConfig.CREATE_INDEX_name_ON_table_USING_GIST_column),
+                            name,
+                            this.table().toString(),
+                            column.getName()
+                        );
+                    } else {
+                        sql = MessageFormat.format(
+                            config.getString(SQLConfig.CREATE_INDEX_name_ON_table_column),
+                            name,
+                            this.table().toString(),
+                            column.getName()
+                        );
+                    }
+                    sqls.add(sql);
+                }
+            }
+            for (Pair<String,String> pair : renames) {
+                StringBuilder builder = new StringBuilder();
+                builder.append("ALTER TABLE ");
+                builder.append(this.table.toString());
+                builder.append(" RENAME COLUMN ");
+                builder.append(identifier(pair.getLeft())); 
+                builder.append(" TO ");
+                builder.append(identifier(pair.getRight())); 
+                sqls.add(builder.toString());
+            }
+            return sqls;
+        }
+
+    }
+    
     protected class H2SpatialCreateTableBuilder extends CreateTableBuilderBase {
 
         @Override
@@ -118,14 +255,16 @@
                 }
                 builder.append(identifier(column.getName()));
                 builder.append(" ");
-                if( column.isGeometry() ) {
-                    String h2geomtype = getH2SpatialGeometryTypeFromGeometryType(
+                builder.append(
+                    sqltype(
+                        column.getType(), 
+                        column.getPrecision(), 
+                        column.getSize(),
                         column.getGeometryType(), 
                         column.getGeometrySubtype()
-                    );
-                    builder.append(h2geomtype);
-                } else {
-                    builder.append(sqltype(column.getType(), column.getPrecision(), column.getSize()));
+                    )
+                );
+                if( !column.isGeometry() ) {
                     if (column.isPrimaryKey()) {
                         builder.append(" PRIMARY KEY");
                     }
@@ -147,8 +286,8 @@
                             builder.append(column.getDefaultValue().toString());
                             builder.append("'");
                         }
+                    }
                 }
-                }
                 if (!column.allowNulls()) {
                     builder.append(" NOT NULL");
                 }
@@ -180,29 +319,6 @@
             
             return sqls;
         }
-        
-        public String getH2SpatialGeometryTypeFromGeometryType(int geomtype, int geomsubtype) {
-            //
-            // https://github.com/orbisgis/h2gis/wiki/1.-Spatial-data#geometry-columns-view
-            //
-            
-            switch(geomtype) {
-            case Geometry.TYPES.POINT:
-                return "POINT";
-            case Geometry.TYPES.MULTIPOINT:
-                return "MULTIPOINT";
-            case Geometry.TYPES.LINE:
-                return "LINESTRING";
-            case Geometry.TYPES.MULTILINE:
-                return "MULTILINESTRING";
-            case Geometry.TYPES.POLYGON:
-                return "POLYGON";
-            case Geometry.TYPES.MULTIPOLYGON:
-                return "MULTIPOLYGON";
-            default:
-                return "GEOMETRY";
-            }
-        }
     }
 
     public class H2SpatialSelectBuilderBase extends SelectBuilderBase {
@@ -317,6 +433,32 @@
         }
     }
 
+    @Override
+    public String sqltype(int type, int p, int s, int geomtype, int geomSubtype) {
+        if( type!=DataTypes.GEOMETRY ) {
+            return super.sqltype(type, p, s, geomtype, geomSubtype);
+        }
+        //
+        // https://github.com/orbisgis/h2gis/wiki/1.-Spatial-data#geometry-columns-view
+        //
+        switch(geomtype) {
+        case Geometry.TYPES.POINT:
+            return "POINT";
+        case Geometry.TYPES.MULTIPOINT:
+            return "MULTIPOINT";
+        case Geometry.TYPES.LINE:
+            return "LINESTRING";
+        case Geometry.TYPES.MULTILINE:
+            return "MULTILINESTRING";
+        case Geometry.TYPES.POLYGON:
+            return "POLYGON";
+        case Geometry.TYPES.MULTIPOLYGON:
+            return "MULTIPOLYGON";
+        default:
+            return "GEOMETRY";
+        }
+    }
+    
     public H2SpatialHelper getHelper() {
         return this.helper;
     }
@@ -365,6 +507,11 @@
             throw new RuntimeException("Can't set parameters to prepared statement from the feature (" + f + ")", ex);
         }
     }
+
+    @Override
+    protected AlterTableBuilder createAlterTableBuilder() {
+        return new H2SpatialAlterTableBuilderBase();
+    }
             
     @Override
     protected TableNameBuilder createTableNameBuilder() {
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java	(revision 43650)
@@ -0,0 +1,131 @@
+
+package org.gvsig.fmap.dal.store.h2.operations;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import org.gvsig.fmap.dal.DataTypes;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.exception.AlreadyEditingException;
+import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
+import org.gvsig.fmap.dal.store.jdbc.exception.JDBCPreparingSQLException;
+import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
+import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation;
+import org.gvsig.tools.dispose.Disposable;
+import org.gvsig.tools.dispose.DisposeUtils;
+
+
+public class H2SpatialAppendOperation extends AppendOperation {
+    
+    public H2SpatialAppendOperation(
+            JDBCHelper helper, 
+            String database,
+            String schema, 
+            String table, 
+            FeatureType type
+        ) {
+        super(helper, database, schema, table, type);
+    }
+    
+    @Override
+    public void begin() throws DataException {
+        if (this.sqlbuilder != null) {
+            throw new AlreadyEditingException(this.helper.getSourceId());
+        }
+
+        try {
+            this.connection = this.helper.getConnectionWritable();
+            
+            this.sqlbuilder = this.helper.createSQLBuilder();
+
+            this.sqlbuilder.insert().table().database(this.database).schema(this.schema).name(this.table);
+            for (FeatureAttributeDescriptor attr : type) {
+                if( attr.isAutomatic() ) {
+                    continue;
+                }
+                if (attr.getType() == DataTypes.GEOMETRY) {
+                    this.sqlbuilder.insert().column().name(attr.getName()).with_value( 
+                        sqlbuilder.parameter(attr.getName()).as_geometry_variable().srs( 
+                                sqlbuilder.parameter().value(attr.getSRS()) 
+                        ) 
+                    );
+                } else {
+                    this.sqlbuilder.insert().column().name(attr.getName()).with_value(
+                        sqlbuilder.parameter(attr.getName()).as_variable()
+                    );
+                }
+            }
+
+            PreparedStatement st;
+            this.sql = this.sqlbuilder.insert().toString();
+            this.preparedStatement = this.connection.prepareStatement(sql);
+            this.connection.setAutoCommit(false);
+            JDBCUtils.execute(this.connection, "SET LOG 1");
+            JDBCUtils.execute(this.connection, "SET LOCK_MODE 1");
+            JDBCUtils.execute(this.connection, "SET UNDO_LOG 0");
+            
+        } catch (SQLException ex) {
+            throw new JDBCPreparingSQLException(this.sqlbuilder.toString(),ex);
+        }
+
+    }
+    
+    @Override
+    protected void clean() {
+        JDBCUtils.closeQuietly(this.preparedStatement);
+        this.helper.closeConnection(this.connection);
+        this.connection = null;
+        this.preparedStatement = null;
+        this.sqlbuilder = null;
+        this.sql = null;        
+    }
+    
+    @Override
+    public void end() {
+        try {
+            this.connection.commit();
+            JDBCUtils.execute(this.connection, "SET LOG 2");
+            JDBCUtils.execute(this.connection, "SET LOCK_MODE 3");
+            JDBCUtils.execute(this.connection, "SET UNDO_LOG 1");
+        } catch (SQLException ex) {
+            try {
+                this.connection.rollback();
+            } catch (SQLException ex1) {
+            }
+            throw new RuntimeException("Can't commit transaction", ex);
+        } finally {
+            clean();
+        }
+    }
+    
+    @Override
+    public void abort() {        
+        try {
+            this.connection.rollback();
+            JDBCUtils.execute(this.connection, "SET LOG 2");
+            JDBCUtils.execute(this.connection, "SET LOCK_MODE 3");
+            JDBCUtils.execute(this.connection, "SET UNDO_LOG 1");
+        } catch (SQLException ex) {
+        }
+        clean();
+    }
+    
+    @Override
+    public void append(FeatureProvider feature) throws DataException {
+        int n;
+        Disposable paramsDisposer = null;
+        try {
+            paramsDisposer = this.sqlbuilder.setParameters(this.preparedStatement, feature);
+            n = JDBCUtils.executeUpdate(this.preparedStatement,this.sql);
+        } catch(Exception ex) {
+            throw new RuntimeException("Can't insert feature.", ex);
+        } finally {
+            DisposeUtils.disposeQuietly(paramsDisposer);
+        }
+        if( n<1 ) {
+            throw new RuntimeException("Can't insert feature (n="+n+").");
+        }
+    }
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialOperationsFactory.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialOperationsFactory.java	(revision 43649)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialOperationsFactory.java	(revision 43650)
@@ -4,8 +4,10 @@
 import java.util.List;
 import org.cresques.cts.IProjection;
 import org.gvsig.fmap.dal.feature.EditableFeatureType;
+import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
+import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation;
 import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation;
 import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ListTablesOperation;
 import org.gvsig.fmap.dal.store.jdbc2.spi.operations.OperationsFactoryBase;
@@ -29,6 +31,11 @@
     public ListTablesOperation createListTables(int mode, JDBCStoreParameters baseParameters, boolean informationTables) {
         return new H2SpatialListTablesOperation(helper, mode, baseParameters, informationTables);
     }
+
+    @Override
+    public AppendOperation createAppend(String database, String schema, String table, FeatureType type) {
+        return new H2SpatialAppendOperation(helper, database, schema, table, type);
+    }
     
     
     
