好好学习,天天向上! avatar

显示MSSQL中的所有视图的SQL语句|show all the views of a database in MSSQL

dailystudy

Published: 03 Feb 2018 › Updated: 03 Feb 2018显示MSSQL中的所有视图的SQL语句|show all the  views of a database in MSSQL

显示MSSQL中的所有视图的SQL语句|show all the views of a database in MSSQL

在LINQpad下查询steemsql数据,因为英语太烂,输入表名经常出错,所以就想把所有表名查询出来,复制到evernote里,需要哪个表直接就可以复制表名。

上网查了一下,在mssql下,显示所有表名的命令如下:

SELECT Name FROM DatabaseName..SysObjects Where XType='U' ORDER BY Name
XType='U':表示所有用户表;
XType='S':表示所有系统表;

于是我便试了:

SELECT Name FROM dbsteem..SysObjects Where XType='U' ORDER BY Name

又试了一下

SELECT Name FROM dbsteem..SysObjects Where XType='S' ORDER BY Name

结果都不行。我一怒之下,试了一下:

SELECT Name FROM dbsteem..SysObjects Where XType='V' ORDER BY Name

成功了,唉,生命在于瞎蒙呀。


然后,我又试了一下这个命令:

SELECT Name FROM SysColumns WHERE id=Object_Id('accounts')

这个命令倒是好用的,可以把视图当成表,查询其中的字段


伪程序员学习日记——边用边学边记——为了以后便于查询,也为了加强记忆。

欢迎各位偶像前来指正,不胜荣幸&感激!

Leave 显示MSSQL中的所有视图的SQL语句|show all the views of a database in MSSQL to:

Written by

伪程序员学习日记! Learning diary of a quasi-programmer

Read more #mssql posts


Best Posts From 好好学习,天天向上!

We have not curated any of dailystudy's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From 好好学习,天天向上!