创建视图

Posted cainiaoaixuexi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创建视图相关的知识,希望对你有一定的参考价值。

CREATE VIEW `wos_tzgg_con` AS select `wos_xxzy_con`.`id` AS `id`,`wos_xxzy_con`.`title`

AS `title`,`wos_xxzy_con`.`code` AS `code`,from_unixtime(`wos_xxzy_con`.`dtime`) AS

`dtime`,‘xw‘ AS `source` from `wos_xxzy_con` where (`wos_xxzy_con`.`iffb` = 1) union select

`dbbinzhou_xxgk`.`yun_news`.`id` AS `id`,`dbbinzhou_xxgk`.`yun_news`.`title` AS

`title`,`dbbinzhou_xxgk`.`yun_news`.`code` AS

`code`,`dbbinzhou_xxgk`.`yun_news`.`pickerdate` AS `dtime`,‘gk‘ AS `source` from

`dbbinzhou_xxgk`.`yun_news` where (`dbbinzhou_xxgk`.`yun_news`.`iffb` = 1) union select

`dbbinzhou_tyhd`.`yun_mail`.`id` AS `id`,`dbbinzhou_tyhd`.`yun_mail`.`title` AS

`title`,`dbbinzhou_tyhd`.`yun_mail`.`indexno` AS `code`,from_unixtime

(`dbbinzhou_tyhd`.`yun_mail`.`dtime`) AS `dtime`,‘smlx‘ AS `source` from

`dbbinzhou_tyhd`.`yun_mail` where (`dbbinzhou_tyhd`.`yun_mail`.`iffb` = 1 and

`dbbinzhou_tyhd`.`yun_mail`.`isopen` = 1) union select `dbbinzhou_tyhd`.`yun_opinion`.`id`

AS `id`,`dbbinzhou_tyhd`.`yun_opinion`.`title` AS

`title`,`dbbinzhou_tyhd`.`yun_opinion`.`id` AS `code`,from_unixtime

(`dbbinzhou_tyhd`.`yun_opinion`.`dtime`) AS `dtime`,‘yjzj‘ AS `source` from

`dbbinzhou_tyhd`.`yun_opinion` where (`dbbinzhou_tyhd`.`yun_opinion`.`iffb` = 1 ) union

select `dbbinzhou_tyhd`.`yun_survey`.`id` AS `id`,`dbbinzhou_tyhd`.`yun_survey`.`title` AS

`title`,`dbbinzhou_tyhd`.`yun_survey`.`code` AS `code`,from_unixtime

(`dbbinzhou_tyhd`.`yun_survey`.`dtime`) AS `dtime`,‘mydc‘ AS `source` from

`dbbinzhou_tyhd`.`yun_survey` where (`dbbinzhou_tyhd`.`yun_survey`.`iffb` = 1 ) union

select `dbbinzhou_zxft`.`zxft_detail`.`id` AS `id`,`dbbinzhou_zxft`.`zxft_detail`.`ft_name` AS

`title`,‘zxftzxft‘ AS `code`,from_unixtime

(`dbbinzhou_zxft`.`zxft_detail`.`ft_ltime_s`) AS `dtime`,‘zxft‘ AS `source` from

`dbbinzhou_zxft`.`zxft_detail` where (`dbbinzhou_zxft`.`zxft_detail`.`ft_iffb` = 1 )
union

select `dbbinzhou_web`.`wos_news_con`.`id` AS `id`,`dbbinzhou_web`.`wos_news_con`.`title` AS

`title`,`qtqt`.`code` AS `code`,from_unixtime

(`dbbinzhou_web`.`wos_news_con`.`dtime`) AS `dtime`,‘qt‘ AS `source` from

`dbbinzhou_web`.`wos_news_con` where (`dbbinzhou_web`.`wos_news_con`.`iffb` = 1 );

以上是关于创建视图的主要内容,如果未能解决你的问题,请参考以下文章

SQL Server里面啥样的视图才能创建索引

sql如何创建视图?

用SQL代码创建一个视图,并查询视图中的字段

如何用SQL语句创建一个视图

sql 如何查看视图的创建用户?

Oracle用户a创建视图,需要给b用户赋予啥权限查看视图?