代码之家  ›  专栏  ›  技术社区  ›  m33n

POSTGRESQL-使外键列指向另一个表

  •  3
  • m33n  · 技术社区  · 8 年前

    我正在使用psql,我想更改表中的一列。

    这是可能的还是应该删除该列并添加一个新列?

    1 回复  |  直到 8 年前
        1
  •  4
  •   Horia Coman    8 年前

    执行前者的命令是:

    alter table Table1 drop constraint if exists name_of_constraint_on_Table_1_column
    

    alter table Table1
    add constraint name_of_constraint_on_Table_1_column
    foreign key (column) references Table3 (other_column) match full
    

    \d 命令:

    \d Table1
    

    alter table 因为你可以做很多事情来改变桌子。