zoukankan      html  css  js  c++  java
  • SQL 判断表、字段是否存在的方法(MSSQL Server、Oracle、MySQL、PostgreSql)

    SQL 判断表、字段是否存在的方法(MSSQL Server、Oracle、MySQL、PostgreSql)

     1、MSSQL Server

    select  count(*)  from  dbo.sysobjects where name=  '表名';  --  表
    select  count(*)  from syscolumns where id=object_id(‘表名’)  and name=  '字段名';  --  字段 

    2、Oracle

    select count(*) from user_objects where  object_name =  '表名';  --  表
    select count(*) from user_tab_columns where table_name = '表名' and column_name = '字段名';   --  字段

    3、MySQL

    select table_name from information_schema.tables where table_name ='表名';    --  表
    select count(*) from information_schema.columns where table_name = '表名' and column_name = '字段名'   --  字段

    4、PostgreSql

    select count(*) from information_schema.tables where table_schema='table_schema' and  table_name ='表名';  --  表
    select count(*) from information_schema.columns where table_schema='table_schema' and table_name ='表名' and  column_name='字段名'; --  字段

    5、其他往期扩展  链接

    创建时间:2021.11.09  更新时间:

  • 相关阅读:
    内存的分页管理方式解释
    分组统计SQL
    NUMA导致的Oracle性能问题
    SQL Server死锁的解决过程
    PHP创建对象的6种方式
    PHP编程20大效率要点
    php设置随机ip访问
    php使用QueryList轻松采集JavaScript动态渲染页面
    正确理解 PHP 的重载
    PHP 核心特性之匿名函数
  • 原文地址:https://www.cnblogs.com/guorongtao/p/15529897.html
Copyright © 2011-2022 走看看