我有三张桌子,一张是另两张的父桌。我想分离出一个列,将其移动到基于FK的子表中。这需要在SQL中完成(没有studio快捷方式)。
TABLE A:
internalID | id | otherdata
============+======+===========
myid | 1 | ...
------------+------+-----------
my2ndid | 2 | ...
------------+------+-----------
1234 | 3 | ...
------------+------+-----------
5678 | 4 | ...
TABLE B:
internalID | FK_toTableA | otherdata
============+===============+===========
NULL | 1 | ...
------------+---------------+-----------
NULL | 2 | ...
TABLE C:
internalID | FK_toTableA | otherdata
============+===============+===========
NULL | 3 | ...
------------+---------------+-----------
NULL | 4 | ...
我想移动或复制
internalID
从
TABLE A
到
TABLE B
&安培;
TABLE C
-基于FK关系,然后从
.
生成的表应如下所示:
TABLE A:
id | otherdata
======+===========
1 | ...
------+-----------
2 | ...
------+-----------
3 | ...
------+-----------
4 | ...
TABLE B:
internalID | FK_toTableA | otherdata
============+===============+===========
myid | 1 | ...
------------+---------------+-----------
my2ndid | 2 | ...
TABLE C:
internalID | FK_toTableA | otherdata
============+===============+===========
1234 | 3 | ...
------------+---------------+-----------
5678 | 4 | ...
SQL版本:13.0.4001.0