Tuesday, April 21, 2009

How to get table structure via SQL?

MS SQL:

SELECT table_name,ordinal_position,column_name,data_type,  is_nullable,character_maximum_length FROM
information_schema.COLUMNS WHERE table_name LIKE '%TABLENAME%'
ORDER BY ordinal_position


or 

EXEC sp_help

MY SQL

SELECT column_name,column_type,is_nullable,column_key,col  umn_default,extra FROM information_schema.COLUMNSWHERE 
table_schema='' AND table_name=''


or

DESCRIBE ;

No comments: