------------------------- Description of SELECTdbo. sysobjects. nameASTableName, dbo. sysproperties. [value] ASTableDescFROMdbo. Role. sysobjectsO
----------------------- MS SQLServer jecjec-- table description SELECT dbo. sysobjects. name AS TableName, dbo. sysproperties. [value] AS TableDesc FROM dbo. sysproperties inner join dbo. sysobjects
--------------------------- MS SQLServer ------------------------------------------------------------
-- Table description
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 = 0)
Order by dbo. sysobjects. name
-- Field description
SELECT dbo. sysobjects. name AS TableName, dbo. syscolumns. colid,
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 = dbo. syscolumns. colid
Order by dbo. sysobjects. name, dbo. syscolumns. colid
-- Primary key and foreign key information (simplified)
Select
C_obj.name as CONSTRAINT_NAME
, T_obj.name as TABLE_NAME
, Col. name as COLUMN_NAME
, Case col. colid
When ref. fkey1 then 1
When ref. fkey2 then 2
When ref. fkey3 then 3
When ref. fkey4 then 4
When ref. fkey5 then 5
When ref. fkey6 then 6
When ref. fkey7 then 7
When ref. fkey8 then 8
When ref. fkey9 then 9
When ref. fkey10 then 10
When ref. fkey11 then 11
When ref. fkey12 then 12
When ref. fkey13 then 13
When ref. fkey14 then 14
When ref. fkey15 then 15
When ref. fkey16 then 16
End as ORDINAL_POSITION
From
Sysobjects c_obj
, Sysobjects t_obj
, Syscolumns col
, Sysreferences ref
Where
Permissions (t_obj.id )! = 0
And c_obj.xtype in (F)
And t_obj.id = c_obj.parent_obj
And t_obj.id = col. id
And col. colid in
(Ref. fkey1, ref. fkey2, ref. fkey3, ref. fkey4, ref. fkey5, ref. fkey6,
Ref. fkey7, ref. fkey8, ref. fkey9, ref. fkey10, ref. fkey11, ref. fkey12,
Ref. fkey13, ref. fkey14, ref. fkey15, ref. fkey16)
And c_obj.id = ref. constid
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 )! = 0
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> 0
And v. number <= I. keycnt
And v. type = P
Order by CONSTRAINT_NAME, ORDINAL_POSITION
-- Primary key and foreign key comparison (simplified)
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 )! = 0
And fc_obj.xtype = F
And r. constid = fc_obj.id
And r. rkeyid = I. id
And r. rkeyindid = I. indid
And r. rkeyid = pc_obj.id
------------------------------------------ ORACLE ----------------------------------------------------
-- Table information
Select * from all_tab_comments t
Where owner = DBO
-- Column information
Select * from all_col_comments t
Where owner = DBO
-- Primary key and foreign key comparison
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)
-- Primary key and foreign key information
Select *
From all_cons_columns
Where owner = DBO
Order by Constraint_Name, Position
-------------------------------------------- Access ----------------------------------------------------
// The system table MSysobjects in Access stores the fields in binary format and cannot be directly analyzed.
// You can use the OpenSchema method provided by ADO to obtain relevant information.
// Use ADOInt. pas
// Po: TableName
// DBCon: TADOConnection
/Ds: TADODataSet
-- Table information
DBCon. OpenSchema (siTables, VarArrayOf ([Null, Null, Table]), EmptyParam, ds );
-- Column information
DBCon. OpenSchema (siColumns, VarArrayOf ([Null, Null, po]), EmptyParam, ds );
-- Primary key
DBCon. OpenSchema (siPrimaryKeys, EmptyParam, EmptyParam, ds );
-- Primary key and foreign key comparison
DBCon. OpenSchema (siForeignKeys, EmptyParam, EmptyParam, ds );