查看表/视图结构

--SQLSERVER
SELECT sysobjects.name AS 表名, syscolumns.name AS 列名,  
systypes.name AS 数据类型, syscolumns.length AS 数据长度 
FROM 
sysobjects INNER JOIN 
syscolumns ON sysobjects.id = syscolumns.id INNER JOIN 
systypes ON syscolumns.xtype = systypes.xtype 
WHERE (sysobjects.xtype = 'u' OR 
sysobjects.xtype = 'v') AND (systypes.name <> 'sysname') 
--and CONVERT(char,sysproperties.[value]) <> 'null' --导出注释不为'null'的记录 
AND (sysobjects.name = 'roi_logs') --逐个关联表名,可以用or连接条件 
ORDER BY 表名

--MySQL
desc 表名;
show columns from 表名;
describe 表名;
show create table 表名;

use information_schema
select * from columns where table_name='表名';

你可能感兴趣的:(mysql,SQL Server)