zoukankan      html  css  js  c++  java
  • SqlServer 、MySQL查询库中表明 字段信息

    SqlServer

    -- sqlserver 查询库中表数量
    
    SELECT count(1) from sysobjects where xtype = 'u'
    
    -- sqlserver 查询表中的字段信息
    select a.name tabelname,
    
    b.name fields,
    
    case c.name when 'numeric' then 'numeric(' + convert(varchar,b.length) + '' + convert(varchar,b.xscale) + ')'
    
    when 'char' then 'char(' + convert(varchar,b.length) + ')'
    
    when 'varchar' then 'varchar(' + convert(varchar,b.length) + ')'
    
    else c.name END AS fieldType
    
    from sysobjects a,syscolumns b,systypes c where a.id=b.id
    
    and a.name='表名' and a.xtype='U'
    
    and b.xtype=c.xtype

    MySQL

    /*MySql查询指定数据库表数量*/
    SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES
    
    WHERE table_schema = 'finance_demo' GROUP BY table_schema;
    
    /*MySql查询指定数据库表名称及注释*/
    select table_name,table_comment from information_schema.tables where table_schema='finance_demo'
    
    /*MySql查询指定数据库表中的字段信息*/
    select COLUMN_NAME,DATA_TYPE,COLUMN_COMMENT from information_schema.COLUMNS where
    table_name = 'dm_settle_platform_details' and table_schema = 'finance_demo';
    学如逆水行舟 不进 则退!
  • 相关阅读:
    Visual Studio for Mac 2017 初体验
    利用栈求表达式的值
    Problem C: ChongQueue
    Problem G: ZL's Prob.2
    Problem F: ZL's Prob.1
    Problem B: ChongBit
    HDU 5156
    SHUOJ 1771
    OpenGL学习整理------着色器
    OpenGL ES着色器语言----------------储存修饰符
  • 原文地址:https://www.cnblogs.com/jmf0529/p/13810051.html
Copyright © 2011-2022 走看看