MySql, Oracle acquisition table structure and field information

1, MySql acquires the configuration information table

The SELECT 
    TABLE_NAME, 
    TABLE_COMMENT 
the FROM 
    information_schema.`TABLES` 
the WHERE 
    the TABLE_SCHEMA =  ' DM '  - DM is the name of the database, need to replace 
the ORDER  BY 
    TABLE_NAME;

 

2, MySql obtain field information

SELECT
    TABLE_NAME AS 'tableName',
    COLUMN_NAME AS 'columnName',
    COLUMN_COMMENT AS 'columnComment',
    IS_NULLABLE AS 'nullable',
    DATA_TYPE AS 'dataType',
    CHARACTER_MAXIMUM_LENGTH AS 'strLength',
    NUMERIC_PRECISION AS 'numLength',
    NUMERIC_SCALE AS ' NumBit ' 
the FROM 
    information_schema.`COLUMNS` 
the WHERE 
    the TABLE_SCHEMA =  ' DM '  - DM is the name of the database, need to replace 
the AND TABLE_NAME =  ' base_auth_resource '  - base_auth_resource is the table name, need to be replaced 
the ORDER  BY 
    TABLE_NAME, 
    the ORDINAL_POSITION;

 

3, Oracle table structure to obtain information

select t.table_name, c.COMMENTS
  from user_tables t, user_tab_comments c
 where t.TABLE_NAME = c.TABLE_NAME
 order by t.table_name

 

4, Oracle acquiring field information

select t.TABLE_NAME     AS tableName,
       t.COLUMN_NAME    AS columnName,
       c.COMMENTS       AS columnComment,
       t.NULLABLE       AS nullable,
       t.DATA_TYPE      AS dataType,
       t.CHAR_LENGTH    AS strLength,
       t.DATA_PRECISION AS numLength,
       t.DATA_SCALE     AS numBit
  from user_tab_columns t, user_col_comments c
 where t.TABLE_NAME = c.TABLE_NAME
   and t.COLUMN_NAME =c.COLUMN_NAME
    and t.TABLE_NAME =  ' the EMP '  - the EMP is a table, need to be replaced 
 Order  by t.TABLE_NAME, t.COLUMN_ID

 

Note: The above sql are actual working code, please note the relevant "database name" or "table" to be replaced.

 

Guess you like

Origin www.cnblogs.com/rulian/p/11593252.html