What is the SQL command to return the field names of a table?

后端 未结 12 1204
野的像风
野的像风 2020-12-05 07:03

Say I have a table called myTable. What is the SQL command to return all of the field names of this table? If the answer is database specific then I need SQL Server right

12条回答
  •  死守一世寂寞
    2020-12-05 07:30

    If you just want the column names, then

    select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'tablename'
    

    On MS SQL Server, for more information on the table such as the types of the columns, use

    sp_help 'tablename'
    

提交回复
热议问题