我需要一些将tsql转换为mysql的帮助:)。
select id,
title,
release_date,
imdb_id,
spoken_languages,
runtime
into [DatabaseDestination].dbo.tableDestination
from [DatabaseSource].dbo.tableSource;
ALTER TABLE [DatabaseDestination].dbo.tableDestination;
ALTER COLUMN id float NOT NULL;
ALTER TABLE [DatabaseDestination].dbo.tableDestination add primary key (id);
您如何在mysql [DatabaseDestination] .dbo.dMovie_details 中进行这种通用引用或导航,以及如何从上面转换代码?
答案 0 :(得分:0)
使用INSERT INTO ... SELECT
:
INSERT INTO db2.tableDestination (id, title, release_date, imdb_id, spoken_languages,
runtime)
SELECT id, title, release_date, imdb_id, spoken_languages, runtime
FROM db1.tableSource;
通常好的做法是总是指定要插入的列,尽管MySQL不需要。我实际上并不知道目标表中的列名,因此我进行了有根据的猜测,并假设它们与源表中的列名相同。
对于其他步骤,应在MySQL中创建目标表时处理架构问题。
答案 1 :(得分:0)
使用插入到---从表中进行选择并进行表导航,例如DatabaseDestination.tableDestination
insert into DatabaseDestination.tableDestination(id, title,release_date, imdb_id, spoken_languages, runtime)
select id, title,release_date, imdb_id, spoken_languages, runtime from DatabaseSource.tableSource;
ALTER TABLE DatabaseDestination.tableDestination
ALTER COLUMN id float NOT NULL;
ALTER TABLE DatabaseDestination.tableDestination add primary key (id);