Skip to content
How to install

Change a table's structure

On a site’s Database tab, Structure above a table’s rows lists its columns, indexes and foreign keys, with the forms that change them.

The Structure view of wp_options, with its columns, its primary key and the buttons that change them
  1. Choose Add column, or Edit beside a column.
  2. Fill in its Name, Type, whether it may be NULL, its Default, a Comment and its Position. A whole-number column can count up by itself. A date-and-time column can take the current time.
  3. Check the SQL under the form, then apply it.

A new type converts every row. A value that does not fit stops the change, but decimals and fractions of a second are rounded without asking.

Drop beside a column removes it, with everything in it.

A generated column, an invisible one, and one with a CHECK constraint of its own have no Edit: the form would lose what makes them so. Change them with SQL. A JSON column stays JSON.

  • Add index makes an index, a unique index or a full-text index on one or more columns. A length indexes only the start of a long text column.
  • A Primary key there takes the place of the one the table has.
  • Add foreign key points columns at another table’s, and says what happens when the row they point at is deleted or its key changes.
  • Drop beside an index or a foreign key removes it.
  • New beside the table filter makes a table: its name, its columns and its primary key. Defaults, comments and indexes come after, in Structure.
  • Rename gives the table a new name. Code that uses the old one stops finding it.
  • Empty deletes every row and keeps the table. Drop deletes the table. Both ask you to type the table’s name.

Each form asks the panel for the SQL it would run, and shows it before you apply it. The panel checks the change against the table as it is, and tries it on an empty copy of the table, so most mistakes are named before anything runs. One that depends on the rows, such as a unique index on values that repeat, fails in the job and changes nothing. The change itself runs as a job, as the site’s own database user, one ALTER TABLE per form.

  • A change waits at most 10 seconds for a table the site is working in. Then it gives up and changes nothing. Try again when the site is quieter.
  • The forms take MariaDB’s usual column types. Change other types, triggers, routines and a view’s query with SQL or in Adminer.
  • MariaDB shows some characters of a default, such as an emoji, as ?. Such a default cannot be kept as it is: the form asks for it again.
  • A table with a full-text index cannot be copied for the try, and a foreign key is not tried: those changes are checked when they run.
  • A change cannot be undone, except from a backup.