zoukankan      html  css  js  c++  java
  • PG判断常见数据库对象是否存在

    • 判断某个表是否存在
    select  * from pg_tables where tablename='tbl_res';
    
    • 判断某个表的某个字段是否存在
    SELECT attname FROM pg_attribute WHERE attname = 'autoid' and  attrelid = 'tbl_version'::regclass;
    
    • 判断某个表的某个约束是否存在
    SELECT conname FROM pg_constraint WHERE conname = 'fk_tbl_ec_info_dev_code' and  conrelid = 'tbl_ec_info'::regclass;
    
    • 判断某个表的索引是否存在
    select * from pg_indexes where tablename='tbl_operlog' and indexname='idx_tbl_operlog_oper_time_operlog_id';
    
    • 判断某个函数是否存在
    select * from pg_proc where proname='func_get_id';
    
    • 判断某个触发器是否存在
    select tgrelid::regclass,tgname, (select proname from pg_proc where oid =tgfoid)  from pg_trigger where tgname='tri_res_name_2_pinyin';
    
    • 判断某个视图是否存在
    select * from pg_views where viewname='videorestable';
    
    • 判断某个类型是否粗在
    select * from pg_type where typname='imos_code';
    
    • 判断某个序列是否存在
    select * FROM information_schema.sequences where  sequence_name='seq_tbl_bank_alarm_record_alarm_id';
    
  • 相关阅读:
    处理溢出
    电梯调度之需求分析
    求二维矩阵和最大的子矩阵
    四则运算改进,结果判断
    结对开发
    四则运算题测试阶段
    阶段二站立会议(2)
    阶段二站立会议(1)
    课程改进意见
    场景调研
  • 原文地址:https://www.cnblogs.com/yldf/p/11899954.html
Copyright © 2011-2022 走看看