博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SQL SERVER导出所有表及表字段
阅读量:7027 次
发布时间:2019-06-28

本文共 1372 字,大约阅读时间需要 4 分钟。

/*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_id
SELECT * FROM sys.columns --所有表字段

转载于:https://www.cnblogs.com/watermarks/p/3793843.html

你可能感兴趣的文章
svn服务器时间与本地时间不同步解决
查看>>
postgres10.2时区研究
查看>>
ie9以下不支持html5 解决方法
查看>>
JAVA异常体系
查看>>
C#'~'按位取反运算符的使用
查看>>
HTTP协议
查看>>
防止SQL注入
查看>>
java.io几种读写文件的方式
查看>>
jquery 点击查看,收起特效
查看>>
JS自学笔记05
查看>>
SQL Server参数化查询中应用Like
查看>>
如何用弹出窗口显示进度
查看>>
mysql优化
查看>>
自动化常识
查看>>
js实现倒计时
查看>>
C#保存文件为无BOM的utf8格式
查看>>
MVC、MVP以及MVVM分析
查看>>
解决Android Studio 错误方法
查看>>
kindeditor用法简单介绍
查看>>
bson.errors.InvalidStringData: strings in documents must be valid UTF-8
查看>>