Describe the structure of the table

What query will give the table structure with column definitions in SQL?

+69
sql database
Jul 29 '10 at 12:02
source share
12 answers

The name of the sp_help table on the sql server is sp_help [ [ @objname = ] 'name' ]

DESCRIBE { table-Name | view-Name } DESCRIBE { table-Name | view-Name } desc in oracle - DESCRIBE { table-Name | view-Name } DESCRIBE { table-Name | view-Name } DESCRIBE { table-Name | view-Name } DESCRIBE { table-Name | view-Name }

+56
Jul 29 '10 at 12:05
source share

It depends on the database you are using. Here is a partial list:

  • .schema table_name : .schema table_name
  • Postgres (psql): \d table_name
  • SQL Server: sp_help table_name (or sp_columns table_name for columns only)
  • Oracle DB2: name- desc table_name or describe table_name
  • MySQL: describe table_name (or show columns from table_name for columns only)
+38
Feb 27 '15 at 16:12
source share

In MySQL you can use DESCRIBE <table_name>

+17
Jul 29 '10 at 12:06 on
source share
 select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='<Table Name>' 

You can get data like column data type and size for this query

+13
Jul 29. '10 at 12:05
source share
 SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'student' 
+8
Jan 01 '16 at 15:03
source share
 DESCRIBE tableName 

Check MySQL describe command

+7
Jul 29 '10 at 12:06 on
source share

Highlight the table name in the console and press ALT + F1

+4
Sep 14 '15 at 3:08
source share

For Sybase aka SQL Anywhere, the following command displays the table structure:

 DESCRIBE 'TABLE_NAME'; 
+4
Oct 29 '15 at 7:10
source share

It depends on the provider of your database. Basically this is an "information scheme" in which you should use Google (applicable to MySQL, MSSQL, and possibly others).

+1
Jul 29 '10 at 12:05
source share

Sql Server

 DECLARE @tableName nvarchar(100) SET @tableName = N'members' -- change with table name SELECT [column].*, COLUMNPROPERTY(object_id([column].[TABLE_NAME]), [column].[COLUMN_NAME], 'IsIdentity') AS [identity] FROM INFORMATION_SCHEMA.COLUMNS [column] WHERE [column].[Table_Name] = @tableName 
0
Jul 29 '10 at 12:12
source share

For SQL, use the sp_help keyword enter image description here

0
Jan 30 '19 at 19:15
source share

In DBTools for Sybase, this is sp_columns your_table_name .

0
Feb 01 '19 at 10:28
source share



All Articles