Home > Database > Mysql Tutorial > body text

Sqlserver列出所有数据库名,表名,字段名【转】

WBOY
Release: 2016-06-07 17:38:08
Original
999 people have browsed it

1.获取所有数据库名: SELECT Name FROM Master..SysDatabases ORDER BY Name 注意: 表Master与SysDatabases之间有两个点 2.获取所有表名: SELECT Name FROM DatabaseName..SysObjects Where XType='U' ORDER BY Name XType='U':表示所有用户表; XType='S':

1.获取所有数据库名:

SELECT Name FROM Master..SysDatabases ORDER BY Name

注意: 表Master与SysDatabases之间有两个点

2.获取所有表名:

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

XType='U':表示所有用户表;

XType='S':表示所有系统表;

3.获取所有字段名:

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!