首页 > 互联资讯 > 技术交流  > 

如何显示数据库的结构?






星河影动之查看数据库结构



<%
on error resume next
table=request("table")
' 获得表名.


if table<>"" then
response.write "
数据表:"&table
Set primary = con.OpenSchema(adSchemaPrimaryKeys, _
Array(empty, empty, table))
if primary("COLUMN_NAME")<>"" then
primarykey=primary("COLUMN_NAME")
end if
primary.close
set primary=nothing
%>












<%sql="select * from ["&table&"] "
set rs=con.execute(sql)
for i=0 to rs.fields.count-1
%>




' 字段长度.



----------------------------------------------------------------------------------------------------------------

' 是否允许空值.


----------------------------------------------------------------------------------------------------------------

' 是否为自动编号.


----------------------------------------------------------------------------------------------------------------

' 主健.


<%next %>

字段


类型


设定大小


允许空值


自动编号
主键

<%=rs(i).name%>


----------------------------------------------------------------------------------------------------------------

' 字段名.



<%
field_type=rs(i).type
select case field_type
case adEmpty
typ = "Empty"
case adTinyInt
typ = "TinyInt"
case adSmallInt
typ = "SmallInt"
case adInteger
typ = "Integer"
case adBigInt
typ = "BigInt"
case adUnsignedTinyInt
typ = "UnsignedTinyInt"
case adUnsignedSmallInt
typ = "UnsignedSmallInt"
case adUnsignedInt
typ = "UnsignedInt"
case adUnsignedBigInt
typ = "UnsignedBigInt"
case adSingle
typ = "Single"
case adDouble
typ = "Double"
case adCurrency
typ = "Currency"
case adDecimal
typ = "Decimal"
case adNumeric
typ = "Numeric"
case adBoolean
typ = "Boolean"
case adError
typ = "Error"
case adUserDefined
typ = "UserDefined"
case adVariant
typ = "Variant"
case adIDispatch
typ = "IDispatch"
case adIUnknown
typ = "IUnknown"
case adGUID
typ = "GUID"
case adDATE
typ = "DATE"
case adDBDate
typ = "DBDate"
case adDBTime
typ = "DBTime"
case adDBTimeStamp
typ = "DBTimeStamp"
case adBStr
typ = "BStr"
case adChar
typ = "Char"
case adVarChar
typ = "VarChar"
case adLongVarChar
typ = "LongVarChar"
case adWChar
typ = "WChar"
case adVarWChar
typ = "VarWChar"
case adLongVarWChar
typ = "LongVarWChar"
case adBinary
typ = "Binary"
case adVarBinary
typ = "VarBinary"
case adLongVarBinary
typ = "LongVarBinary"
case adChapter
typ = "Chapter"
case adPropVariant
typ = "PropVariant"
case else
typ = "Unknown"
----------------------------------------------------------------------------------------------------------------

end select
response.write typ%>
' 字段类型.



<%=rs(i).definedsize%>



<%
attrib=rs(i).attributes
if (attrib and adFldIsNullable)=0 then
response.write "No"
else
response.write "Yes"
end if
%>



<%if rs(i).Properties("ISAUTOINCREMENT") = True then%>

<%else%>

<%end if%>



<%if rs(i).name=primarykey then%>

<%else%>

<%end if%>


[1]

如何显示数据库的结构?由讯客互联技术交流栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“如何显示数据库的结构?