表X已经存在,使用Create view X as - MySql

时间:2012-12-31 18:31:44

标签: mysql view create-table

我在做:

create view WritersCouples as
select researcher.serial_number as S1, researcher.firstname as S2
from researcher, researcher as rs
where researcher.serial_number <> rs.serial_number;

我收到以下错误:

Error Code: 1050. Table 'WritersCouples' already exists

我在mySql上使用工作台

谢谢!

3 个答案:

答案 0 :(得分:1)

您是否已创建视图?或者你已经有一个名为WritersCouples的表?

你可以试试这个:

create or replace view WritersCouples as
select researcher.serial_number as S1, researcher.firstname as S2
from researcher, researcher as rs
where researcher.serial_number <> rs.serial_number;

如果视图已经存在,那将取代视图。

答案 1 :(得分:1)

如果视图已存在,请添加OR REPLACE子句:

create OR REPLACE view WritersCouples as
select researcher.serial_number as S1, researcher.firstname as S2
from researcher, researcher as rs
where researcher.serial_number <> rs.serial_number;

答案 2 :(得分:1)

添加以下内容:

create or replace view myview
as
select ....