表說明
SELECT dbo
sysobjects
name AS TableName
dbo
sysproperties
[value] AS TableDesc
FROM dbo
sysproperties INNER JOIN
dbo
sysobjects ON dbo
sysproperties
id = dbo
sysobjects
id
WHERE (dbo
sysproperties
smallid =
)
ORDER BY dbo
sysobjects
name
字段說明
SELECT dbo
sysobjects
name AS TableName
lid
dbo
syscolumns
name AS ColName
dbo
sysproperties
[value] AS ColDesc FROM dbo
sysproperties INNER JOIN
dbo
sysobjects ON dbo
sysproperties
id = dbo
sysobjects
id INNER JOIN
dbo
syscolumns ON dbo
sysobjects
id = dbo
syscolumns
id AND
dbo
sysproperties
smallid = lid
ORDER BY dbo
sysobjects
name
lid
主鍵
外鍵信息(簡化)
select
c_obj
name as CONSTRAINT_NAME
t_obj
name as TABLE_NAME
col
name as COLUMN_NAME
case lid
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
when ref
fkey
then
end as ORDINAL_POSITION
from
sysobjects c_obj
sysobjects t_obj
syscolumns col
sysreferences ref
where
permissions(t_obj
id) !=
and c_obj
xtype in (
F
)
and t_obj
id = c_obj
parent_obj
and t_obj
id = col
id
and lid in
(ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
ref
fkey
)
and c_obj
id = nstid
union
select
i
name as CONSTRAINT_NAME
t_obj
name as TABLE_NAME
col
name as COLUMN_NAME
v
number as ORDINAL_POSITION
from
sysobjects c_obj
sysobjects t_obj
syscolumns col
master
dbo
spt_values v
sysindexes i
where
permissions(t_obj
id) !=
and c_obj
xtype in (
UQ
PK
)
and t_obj
id = c_obj
parent_obj
and t_obj
xtype =
U
and t_obj
id = col
id
and col
name = index_col(t_obj
name
i
indid
v
number)
and t_obj
id = i
id
and c_obj
name = i
name
and v
number >
and v
number <= i
keycnt
and v
type =
P
order by CONSTRAINT_NAME
ORDINAL_POSITION
主鍵
外鍵對照(簡化)
select
fc_obj
name as CONSTRAINT_NAME
i
name as UNIQUE_CONSTRAINT_NAME
from
sysobjects fc_obj
sysreferences r
sysindexes i
sysobjects pc_obj
where
permissions(fc_obj
parent_obj) !=
and fc_obj
xtype =
F
and nstid = fc_obj
id
and r
rkeyid = i
id
and r
rkeyindid = i
indid
and r
rkeyid = pc_obj
id
ORACLE
表信息
select * from all_tab_comments t
where owner=
DBO
列信息
select * from all_col_comments t
where owner=
DBO
主鍵
外鍵對照
select OWNER
CONSTRAINT_NAME
CONSTRAINT_TYPE
TABLE_NAME
R_OWNER
R_CONSTRAINT_NAME
from all_constraints
where owner=
DBO
and (Constraint_Type=
P
or Constraint_Type=
R
)
主鍵
外鍵信息
select *
from all_cons_columns
where owner=
DBO
order by Constraint_Name
Position
Access
//Access中的系統表MSysobjects存儲屬性的字段是二進制格式
不能直接分析可以采用ADO自帶的OpenSchema方法獲得相關信息
//use ADOInt
pas
//po: TableName
//DBCon:TADOConnection
/ds:TADODataSet
表信息
DBCon
OpenSchema(siTables
VarArrayOf([Null
Null
Table
])
EmptyParam
ds);
列信息
DBCon
OpenSchema(siColumns
VarArrayOf([Null
Null
po
])
EmptyParam
ds);
主鍵
DBCon
OpenSchema(siPrimaryKeys
EmptyParam
EmptyParam
ds);
主鍵
外鍵對照
DBCon
OpenSchema(siForeignKeys
EmptyParam
EmptyParam
ds);
From:http://tw.wingwit.com/Article/program/MySQL/201311/29331.html