ITPub博客

首页 > 应用开发 > IT综合 > Another way to rename a column

Another way to rename a column

原创 IT综合 作者:tsinglee 时间:2007-10-22 16:25:14 0 删除 编辑
Another way to rename a column is to use the RENAME statement together with the
CREATE TABLE statement with AS subquery. This method is useful if you are
changing the structure of a table rather than only renaming a column. The
following statements re-create the sample table hr.job_history, renaming a column from
department_id to dept_id:
CREATE TABLE temporary
(employee_id, start_date, end_date, job_id, dept_id)
AS SELECT
employee_id, start_date, end_date, job_id, department_id
FROM job_history;
DROP TABLE job_history;
RENAME temporary TO job_history;
Any integrity constraints defined on table job_history will be lost in the
preceding example. You will have to redefine them on the new job_history table using an
ALTER TABLE statement.[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10599713/viewspace-978047/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 昨晚下雪了
请登录后发表评论 登录
全部评论
  • 博文量
    740
  • 访问量
    1930081