sql server 视图添加一列

chestnut chestnut 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
有个视图,想在视图中增加一列id,自动增长。原本视图数据是:

city code
广州 1111A
深圳 123A
厦门 159A

实现效果是:
id city code
1 广州 1111A
2 深圳 123A
3 厦门 159A

原来视图的脚本是:
if exists (select * from sys.objects where name ='test')
drop table test;
create table test (city varchar(10),code varchar(10))
insert into test
select '广州','1111A' union all
select '深圳', '123A' union all
select '厦门', '159A'
if exists (select * from sys.objects where name ='vtest')
drop view vtest;
create view vtest as select * from test;

是想在建视图的时候添加一列,不是在基础表添加一列!!!
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
chestnut
MS-SQL Server 34,876 成员 254,635 内容