/*Goal:MS SQL SERVER:Output all the field and its’ tableauthor:AllisonHuangcreated date :20140613*/--select [id], [name] from [sysobjects] where [type] = 'u' order by [name]drop table #tempingcreate table #temping (id varchar(200),name varchar(200),namedetail varchar(200))--SELECT name,id FROM SysColumns WHERE id=Object_Id('ABUSEDSTOCK') declare @id varchar(20)declare @name varchar(20)declare cursor1 cursor for --定义游标cursor1select [id], [name] from [sysobjects] where [type] = 'u' order by [name]open cursor1 --打开游标fetch next from cursor1 into @id,@Name --将游标向下移行,获取的数据放入之前定义的变量@id,@NUM中while @@fetch_status=0 --判断是否成功获取数据begininsert into #temping SELECT id,@name,name FROM SysColumns WHERE id=Object_Id(@Name) --id is Object_Id(@Name)'s id ,not [sysobjects]'s.fetch next from cursor1 into @id,@Name --将游标向下移行endclose cursor1 --关闭游标deallocate cursor1select * from #temping
oracle:
导出所有表名+字段名:
select t.TABLE_NAME 表名 ,t.COLUMN_ID 序号 ,t.COLUMN_NAME 字段名 ,t.DATA_TYPE 类型 ,t. DATA_LENGTH 长度 ,t.NULLABLE 是否为空
from user_tab_columns t
其他:
SELECT OBJECT_NAME(sc.object_id)TABLE_NAME ,* FROM sys.index_columns SC
SELECT OBJECT_NAME(I.object_id),* FROM sys.indexes I
--AND sc.object_id = i.object_id--AND sc.index_id = i.index_idSELECT * FROM sys.columns --所有表字段