Http://www.blogjava.net/bukebushuo/archive/2008/07/05/212794.html
Recently, I have been studying tools for generating java files based on the table structure,
How to obtain various table information and comments when obtaining table fields,
This problem has plagued me. After searching by multiple parties, I found the following information for backup:
ORACLE:
User_tab_comments; Table comment
User_col_comments; Table field comment
The preceding two tables can only obtain comments of their own tables. To access tables of other users that you can access, you need:
All_tab_comments; Table comment
All_col_comments; Table field comment
Of course, you can use
Dba_tab_comments; Table comment
Dba_col_comments; Table field comment
It is best to specify the owner condition for DBA * And all. User * does not have this field
MSSQL:
Select B. [value]
From syscolumns a left join sysproperties B on A. ID = B. ID
And a. colid = B. smallid inner join sysobjects C on A. ID = C. ID
And a. [name] = 'column name' and C. [name] = 'table name'
Select
Table name = case when a. colorder = 1 then D. Name else ''end,
Table description = case when a. colorder = 1 then isnull (F. Value, '') else'' end,
FIELD No. = A. colorder,
Field name = A. Name,
Id = case when columnproperty (A. ID, A. Name, 'isidentity ') = 1 then' √ 'else' end,
Primary Key = case when exists (select 1 from sysobjects where xtype = 'pk' and name in (
Select name from sysindexes where indid in (
Select indid from sysindexkeys where id = A. ID and colid = A. colid
) Then' √ 'else' end,
Type = B. Name,
Bytes occupied = A. length,
Length = columnproperty (A. ID, A. Name, 'precision '),
Decimal places = isnull (columnproperty (A. ID, A. Name, 'Scale'), 0 ),
Allow null = case when a. isnullable = 1 then '√ 'else' 'end,
Default Value = isnull (E. Text ,''),
Field description = isnull (G. [value], '')
From syscolumns
Left join policypes B on A. xusertype = B. xusertype
Inner join sysobjects D on A. ID = D. id and D. xtype = 'U' and D. Name <> 'dtproperties'
Left join syscomments e on A. cdefault = E. ID
Left join sysproperties g on A. ID = G. ID and A. colid = G. smallid
Left join sysproperties F on D. id = f. ID and F. smallid = 0
-- Where D. Name = 'Orders '-- if only the specified table is queried, add this condition.
Order by A. ID, A. colorder