Online Documentation for SQL Manager for PostgreSQL

Changing columns order


The Reorder Columns dialog allows you to change the columns order in the table.

 

To open this dialog, open the table in Table Editor, proceed to the Columns tab there, right-click within the Columns list and select the Reorder Columns item from the context menu.

 

NB: Since PostgreSQL server does not have a native command for reordering table columns, this operation is implemented in SQL Manager for PostgreSQL by generating the script according to which the data of the original table are copied into a temporary table, then the original table is dropped, and a new table with the same name but having the newly specified order of columns is created, and afterwards all the data are copied from the temporary table into the new one.

Nevertheless such script cannot be executed in some cases. If a table is referenced by another table (e.g. there is a Foreign Key constraint) or is a base table for a view, the Reorder Columns operation cannot be performed. It is recommended to drop Foreign Keys before column reordering, and create them again after the reordering operation is completed.

 

By default, before the Reorder Columns dialog is opened, a warning window is displayed. Use the Operations by recreating drop-down list to specify whether the Reorder Columns operation will be available after the current operation is performed:

Enabled - such operation will be performed without warnings;

Enabled, show warning - the warning window will appear if the operation requires table recreation;

Disabled - denies operations of this type.

 

Note: You can change this value any time using the Table altering operations performed via recreation drop-down list available on the Confirmations page of the Environment Options dialog.

 

Table Editor - Changing fields order - Warning

 

The columns are displayed in the Column name list in the current order.

To change the columns order, use the btnReorderItems_MoveUp btnReorderItems_MoveDown buttons or drag-and-drop operations within the list. Click the OK button to view the modification script in the Changing Metadata window and apply changes.

 

Table Editor - Changing fields order