Removing Columns After Table Creation Using SQL

Click For Summary

Discussion Overview

The discussion centers around the ability to remove columns from a database table after its creation, exploring the implications and methods of doing so within SQL, particularly in MySQL. The conversation touches on theoretical and practical aspects of database schema management.

Discussion Character

  • Debate/contested
  • Technical explanation

Main Points Raised

  • One participant questions the possibility of deleting columns after table creation, noting that while rows can be removed easily, columns cannot.
  • Another participant references MySQL documentation, indicating that columns can be deleted using the ALTER TABLE statement.
  • A participant emphasizes the fundamental differences between columns and rows, suggesting that the ability to modify one does not imply the same for the other, while also stating that good database design should allow for column deletion unless constraints are in place.
  • Some participants express that altering the schema by removing columns is generally discouraged, particularly outside of prototyping scenarios, raising concerns about the implications of changing data structures at runtime.
  • There is a reiteration that altering the schema is acceptable if the initial schema was incorrect, questioning the rationale behind maintaining a flawed structure.
  • A participant notes that the command to remove columns is a Data Definition Language (DDL) command and is specific to the SQL language being used.

Areas of Agreement / Disagreement

Participants exhibit disagreement regarding the appropriateness and implications of removing columns from a table after creation. While some acknowledge the technical feasibility, others caution against the practice, indicating a lack of consensus on the best approach.

Contextual Notes

Participants highlight that the ability to delete columns may depend on existing constraints and the specific SQL dialect being used, indicating potential limitations in the discussion.

ponjavic
Messages
221
Reaction score
0
Isn't possible to delete and remove columns after a table has been created?
Rows works just fine but columns don't...
 
Computer science news on Phys.org
in MySQL, this is done with http://dev.mysql.com/doc/mysql/en/ALTER_TABLE.html
 
Last edited by a moderator:
Note that columns and rows in a database are very different things, so the fact that you can do something to a row doesn't automatically mean you should be able to do the same thing to a column.


Still, any good database should allow you to delete a column unless you've deliberately added constraints that would prevent it. But you have to modify the table to do that, usually with an ALTER TABLE statement.
 
You can, but its not considered a good thing to do, except possibly when prototyping. This is because you are altering your schema, which shouldn't happen. Would you want to alter the form of a data structure at runtime?
 
so-crates said:
You can, but its not considered a good thing to do, except possibly when prototyping. This is because you are altering your schema, which shouldn't happen. Would you want to alter the form of a data structure at runtime?

If your schema is wrong, why wouldn't you change it?
 
It is a DDL command and is language specific.
 

Similar threads

Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 51 ·
2
Replies
51
Views
6K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 14 ·
Replies
14
Views
7K
  • · Replies 7 ·
Replies
7
Views
2K