How can I retrieve the table structure from a sql database?

972 views Asked by At

So basically I want a SQL Command that return every column in the table and the datatype that is in that column and whether is nullable.

1

There are 1 answers

1
SQLChao On BEST ANSWER

You can use information schema.

SELECT 
  COLUMN_NAME,
  DATA_TYPE, 
  IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'yourTableName'