oracle has 'DESCRIBE' to get all the detai

2019-02-20 15:29发布

问题:

oracle has 'DESCRIBE' to get all the details of the table like wise does t/sql has any thing.

回答1:

SQL Server has sp_help/sp_helptext

MySQL has describe



回答2:

Sql-Server's sp_help is about as close as you get for something built-in. Remeber to put the tablename in as a parameter...:-)

EXEC sp_help 'mytable'

If you're in ssms, you can r-click your query window and opt to output results to text -- it's a little easier to read the output.

ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/913cd5d4-39a3-4a4b-a926-75ed32878884.htm

Also -- you can write your own using the system tables (sys.objects, sys.columns, ...) I think 'DESCRIBE' just gives you column name, nullable, and type... so not nearly as much as sp_help provides.



回答3:

SELECT * FROM sysobjects WHERE parent_obj = (SELECT id FROM sysobjects WHERE name = 'table_name') AND xtype='PK'

will show table details.

SELECT * FROM sys.Tables

will list all tables

There is no describe equivalent. you might find this searching for MSSQL instead of T/SQL. Most people talking about Transact SQL are talking about stored procedures.



标签: tsql