如何更改mysql中新创建的VIEW中的属性?

时间:2013-05-10 23:03:25

标签: mysql rename

所以我创建了一个视图,并希望用新名称显示视图的新列,例如:

CREATE VIEW monthly_view AS
(SELECT co.object_id, co.object_alias, cm.method_alias, dr.data_value,
           cd.data_uom, dr.date_timestamp, dr.delay_value, dr.delay_pct
FROM data_realtime AS dr
JOIN chroniker_object AS co ON co.object_id=dr.object_id
JOIN chroniker_data AS cd ON cd.data_id=dr.data_id
JOIN chroniker_method AS cm ON cm.method_id=co.method_id)

我想要的是每当显示“monthly_view”时,“co.object_id”可以显示为“对象”。

由于

3 个答案:

答案 0 :(得分:2)

您可以使用别名:

CREATE VIEW monthly_view AS
SELECT co.object_id AS Object,
       co.object_alias AS ...,
       cm.method_alias AS ...,
       ...
FROM
       ...

答案 1 :(得分:0)

select co.object_id AS object, ....

答案 2 :(得分:0)

您是否尝试过在select语句中提供别名?

CREATE VIEW monthly_view AS
(SELECT co.object_id AS Object, 
        co.object_alias AS ObjectAlias, 
        ....
FROM data_realtime AS dr
JOIN chroniker_object AS co ON co.object_id=dr.object_id
JOIN chroniker_data AS cd ON cd.data_id=dr.data_id
JOIN chroniker_method AS cm ON cm.method_id=co.method_id)