Добавьте столбец к таблице DB2/400 с определенным порядковым положением

Меню XCode-> Ясный кэш решило мою проблему.

5
задан jwl 20 October 2009 в 15:15
поделиться

2 ответа

IBM i 7.1 теперь позволяет добавлять столбец перед другим столбцом.

ALTER TABLE table ADD COLUMN colname ... BEFORE othercolumn

8
ответ дан 18 December 2019 в 13:16
поделиться

No. The ALTER TABLE statement will allow you add a column to a table, but, according to the documentation:

The new column is the last column of the table; that is, if initially there are n columns, the added column is column n+1.

If you'd like to change the order of columns in your table, your best bet is to:

  1. Use the RENAME statement to rename the table.
  2. Recreate the table, with its original name, with the columns in the order that you want.
  3. Use an INSERT SELECT to populate the new table with the data from the renamed table.
  4. Если вы уверены, что данные не повреждены, вы можете удалить переименованную версию таблицы.
6
ответ дан 18 December 2019 в 13:16
поделиться
Другие вопросы по тегам:

Похожие вопросы: