Удаление столбцов в SQL Server MS

Вы можете использовать метод python replace(...), чтобы заменить все разрывы строк HTML-версией <br> и, возможно, заключить строку в тег абзаца <p>...</p>. Допустим, имя переменной с текстом: text:

html = "<p>" + text.replace("\n", "<br>") + "</p>"
43
задан Tony L. 28 April 2016 в 14:29
поделиться

3 ответа

The command you're looking for is:

alter table tblName drop column columnName

where tblName is the name of the table and columnName is the name of the column, but there's a few things you may need to do first.

  • If there are any foreign key references to the column, you'll need to get rid of them first.
  • If there's an index using that column, you'll need to either get rid of it or adjust it to not use that column.

Keep in mind that the performance of this command may not necessarily be good. One option is to wait for a down-time period when you can be certain no-one will be accessing the database, rename the current table, then use create table and insert into ... select from to transfer the columns you don't want deleted.

One of the later releases of Oracle actually has a soft delete which can just marks a column as unused without removing it physically. It has the same effect since you can no longer reference it and there's a command along the lines of alter table ... drop unused columns which is meant to be run in quiet time, which does the hard work of actually removing it physically.

This has the advantage of "disappearing" the columns immediately without dragging down database performance during busy times.

94
ответ дан 26 November 2019 в 22:35
поделиться

ALTER TABLE XXX DROP COLUMN YYY;

13
ответ дан 26 November 2019 в 22:35
поделиться

Для больших таблиц это может быть очень медленный. Часто может быть намного быстрее создать новую таблицу, дубликат старой, но с изменениями, и вставить данные. Удалите старую таблицу, а затем переименуйте новую таблицу.

3
ответ дан 26 November 2019 в 22:35
поделиться
Другие вопросы по тегам:

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