1.oracle数据库
select count( column_name )
from user_tab_columns
where table_name = '表名'; --表名为大写
2.sqlserver数据库
select count(syscolumns.name)
from syscolumns , sysobjects
where syscolumns.id = sysobjects.id
and sysobjects.name = '表名'