如何在使用内部联接合并两个表时将列设置为PRIMARY KEY
?(两个连接表中没有主键)请帮助
create table merge_aws AS
select aws.id,aws.date,aws.time,aws.pmer,aws.dd,aws.ff,aws.t,masterfile.station,masterfile.latitude,masterfile.longitude
from aws
inner join masterfile
on aws.id=masterfile.call_sign;
答案 0 :(得分:0)
创建后使用alter table,如下例所示:
CREATE TABLE merge_aws AS select
aws.id,
aws.date,
aws.time,
aws.pmer,
aws.dd,
aws.ff,
aws.t,
masterfile.station,
masterfile.latitude,
masterfile.longitude
from
aws
inner join
masterfile ON aws.id = masterfile.call_sign;
ALTER TABLE merge_aws ADD COLUMN prim INT NOT NULL AUTO_INCREMENT , ADD PRIMARY KEY (prim) ;
谢谢