码迷,mamicode.com
首页 > 数据库 > 详细

[转]SQL 读取表结构

时间:2019-05-26 22:29:57      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:where   http   form   data   sele   HERE   efault   mys   user   

1、Sql
SELECT column_name as FName,data_type as FType,CHARACTER_MAXIMUM_LENGTH as FLen from information_schema.columns where table_name=‘" + Table + "‘";
SELECT b.name, a.name FName from sysobjects b join syscolumns a on b.id = a.cdefault where a.id = object_id(‘" + Table + "‘) ";

2、Oracle
SELECT DATA_LENGTH AS LEN FROM USER_TAB_COLUMNS WHERE UPPER(TABLE_NAME)=‘" + Table.ToUpper() + "‘ AND UPPER(COLUMN_NAME)=‘" + Field.ToUpper() + "‘"
SELECT DATA_TYPE,OWNER FROM ALL_TAB_COLUMNS WHERE upper(TABLE_NAME)=‘" + Table.ToUpper() + "‘ AND UPPER(COLUMN_NAME)=‘" + Field.ToUpper() + "‘"

3、MySql
select character_maximum_length as Len, table_schema as OWNER,DATA_TYPE FROM information_schema.columns WHERE TABLE_SCHEMA=‘" + DBDatabase + "‘ AND table_name =‘" + Table + "‘ and column_Name=‘" + Field + "‘"

 

来自:https://gitee.com/opencc

[转]SQL 读取表结构

标签:where   http   form   data   sele   HERE   efault   mys   user   

原文地址:https://www.cnblogs.com/z5337/p/10928009.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!