Search code examples
javadatabasederbydatabase-administration

Altering an Apache Derby table's derby.storage.pageSize property after creation


Is it possible to change the derby.storage.pageSize property of an existing table? Or do I have to export my data, drop then re-create the table with the new property, and then re-import my data?


Solution

  • The doc says:

    Defines the page size, in bytes, for on-disk database pages for tables or indexes used during table or index creation. Set this property prior to issuing the CREATE TABLE or CREATE INDEX statement. This value will be used for the lifetime of the newly created conglomerates.

    So it will only be used when creating the table and will be valid until the table is deleted.
    You will have to delete, create and re-import.

    Bryan Pendleton mentioned create table as select but at the moment this does not work completely. Data cannot be inserted automatically.

    CREATE TABLE ... AS ...

    With the alternate form of the CREATE TABLE statement, the column names and/or the column data types can be specified by providing a query. The columns in the query result are used as a model for creating the columns in the new table.

    If no column names are specified for the new table, then all the columns in the result of the query expression are used to create same-named columns in the new table, of the corresponding data type(s). If one or more column names are specified for the new table, then the same number of columns must be present in the result of the query expression; the data types of those columns are used for the corresponding columns of the new table.

    The WITH NO DATA clause specifies that the data rows which result from evaluating the query expression are not used; only the names and data types of the columns in the query result are used. The WITH NO DATA clause must be specified; in a future release, Derby may be modified to allow the WITH DATA clause to be provided, which would indicate that the results of the query expression should be inserted into the newly-created table. In the current release, however, only the WITH NO DATA form of the statement is accepted.