2009年2月15日星期日

SQL之DROP COLUMN的workaround

如果数据库(db2 v8, db2z, db2i)不提供drop column(有的特殊字段也不能drop的,如xml字段),怎么办呢?

原来的表是t1
1. 创建表t1', 它不含有应该drop的column
2. insert into t1' select x,x,x from t1
3. drop table t1
4. rename t1' to t1

没有评论: