mysql 表及字段注释
-- 查询表注释 select table_schema, table_name, table_comment from information_schema.tables where table_schema = '数据库名' and table_name = '表名'; -- 查询表字段注释 select table_schema, table_name, column_name, column_comment from information_schema.columns where table_schema = '数据库名' and table_name = '表名';
生成SQL Server有注释
set @mssql_table_name = 'mssql表名'; set @table_name = '表名'; set @db_name = '数据名'; -- 查询表注释 select concat('execute sp_addextendedproperty \'MS_Description\',N\'',table_comment,'\',\'user\',\'dbo\',\'table\',\'',@mssql_table_name,'\',null,null;') as sqlStr from information_schema.tables where table_schema = @db_name and table_name = @table_name; -- 查询表字段注释 select concat('EXECUTE sp_addextendedproperty N\'MS_Description\',N\'',column_comment,'\', N\'SCHEMA\', N\'dbo\', N\'TABLE\', N\'',@mssql_table_name,'\', N\'COLUMN\', N\'',column_name,'\';') as sqlStr from information_schema.columns where table_schema = @db_name and table_name = @table_name;