我可以使用哪个 SQL 命令来查看 SQL Server 上表的结构?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3159236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 06:44:47  来源:igfitidea点击:

Which SQL command can I use to see the structure of a table on SQL Server?

sqlsql-serverstructure

提问by Thiago Le?o Moreira

I have a table on a SQL Server and I would like to export its structure to send to a colleague. Which SQL command should I issue to get the structure? I don't have access to the SQL Server Management Studio.

我在 SQL Server 上有一个表,我想导出它的结构以发送给同事。我应该发出哪个 SQL 命令来获取结构?我无权访问 SQL Server Management Studio。

回答by Baaju

sp_help '<TableName>'

will give you the structure of a table

会给你一个表的结构

Also you can use the information_Schema to get a detailed information,

您也可以使用 information_Schema 获取详细信息,

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TableName' 

Check this out http://msdn.microsoft.com/en-us/library/ms186778.aspx

看看这个http://msdn.microsoft.com/en-us/library/ms186778.aspx

回答by etliens

Brad Schulz has a pretty awesome DDL generating script he just blogged about the other day: (there are a few limitations with it though)

Brad Schulz 有一个非常棒的 DDL 生成脚本,他前几天刚在博客上写过:(不过它有一些限制)

http://bradsruminations.blogspot.com/2010/06/more-fun-with-hyperlinks-ddl-code.html

http://bradsruminations.blogspot.com/2010/06/more-fun-with-hyperlinks-ddl-code.html

回答by BC.

Visual Studio has tools for designing and browsing database schema under Data Connections in Server Explorer. Certain versions also have full schema and data comparison tools similiar to Red Gate's Sql Compare

Visual Studio 具有用于在服务器资源管理器中的数据连接下设计和浏览数据库架构的工具。某些版本还具有类似于Red Gate 的 Sql Compare 的完整架构和数据比较工具