加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – Postgres alter view add column

发布时间:2020-12-13 18:09:34 所属栏目:百科 来源:网络整理
导读:我想改变一个视图并在其中添加一个新列.我有: ALTER VIEW folders_contentsASSELECT files.id,files.name,files.filesize,files.updated,files.deleted,FROM filesUNION ALL SELECT folders.id,folders.name,0 AS filesize,folders.updated,folders.deleted
我想改变一个视图并在其中添加一个新列.我有:
ALTER VIEW folders_contents
AS
SELECT files.id,files.name,files.filesize,files.updated,files.deleted,FROM files
UNION ALL
 SELECT folders.id,folders.name,0 AS filesize,folders.updated,folders.deleted,FROM folders
  ORDER BY 8,2
GO

问题是它显示:

[Err] ERROR: syntax error at or near “AS”

这是我第一次看到视图,我需要一些帮助:)

ALTER VIEW changes various auxiliary properties of a view. 
(If you want to modify the view's defining query,use CREATE OR REPLACE VIEW.)

使用CREATE或REPLACE INSTEAD

在你的情况下,它将是这样的:

CREATE OR REPLACE VIEW folders_contents
AS
SELECT files.id,2;

SOURCE

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读