如何在sql中的现有视图中添加列 [英] How to add a column in a existing view in sql

查看:2114
本文介绍了如何在sql中的现有视图中添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个表( EMP_DETAILS ),其中包含 EMP_ID(主键),FIRST_NAME,LAST_NAME,AGE,ADDRESS,SALARY,DEPT_ID(外键) 。我想创建一个这个表的视图。



我已经为表创建了一个视图,但是当我创建该表时,我错过了一个列( FIRST_NAME )。



我想在这个现有视图中添加该列,并将其删除。我已经尝试更换它但它没有显示任何内容。



有人可以帮我解决这个问题。



我有另一个问题:

我如何将上表视图加入另一个表格视图

(DEP_DETAILS){DEPT_ID(主键),DEPT_NAME}



能否帮我提供实际语法。

I already have a table (EMP_DETAILS), which is containing EMP_ID (Primary Key), FIRST_NAME, LAST_NAME, AGE, ADDRESS, SALARY, DEPT_ID (Foreign Key). I want to create a view of this table.

I already created a view for the table, but when I created that table I missed one column (FIRST_NAME).

I want to add that column in this existing view with out drop this. I already try to replace this but it had shown some nothing.

Can anybody please help me out from this.

I have another question:
How I join the above table view with the another table view
(DEP_DETAILS){DEPT_ID (Primary Key), DEPT_NAME}

Can you please help me to giving the actual syntax.

推荐答案

使用 ALTER VIEW ,使用您想要的正确选择查询:http://msdn.microsoft.com/en-us/library/ms173846.aspx [ ^ ]



使用查询构建器通过所需的连接创建所需的select语句,然后为该select语句创建一个视图。
Use ALTER VIEW with the correct select query you want : http://msdn.microsoft.com/en-us/library/ms173846.aspx[^]

Use the query builder to create the select statement you want with the joins you need then create a view for that select statement.


根据您正在使用的注释sql server 2008与oracle sql developer。有一个更好的微软产品叫做 sql server management studio express [ ^ ],它是免费的。

你可以右键点击视图并直接设计
as per your comment you are working with sql server 2008 with oracle sql developer. there is a better microsoft product called sql server management studio express[^], it is free.
you can right click on view and design it directly


这篇关于如何在sql中的现有视图中添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆