PostgreSQL判断表是否存在最快的方法
来源:互联网 发布:linux shell 判断大小 编辑:程序博客网 时间:2024/05/17 05:55
1.使用to_regclass函数(首选方法)
速度最快,9.4或更高版本首选这个函数
if( to_regclass('test') is null ) then你的代码end if;
或包含架构
if( to_regclass('public.test') is null ) then/*你的代码*/end if;
2.使用pg_class系统表
if( (select 1 from pg_class where relname='test'::name and relkind='r') is null ) then/*你的代码*/end if;
如果要包含架构可以使用下面的方法
if( (select 1 from pg_class as c join pg_namespace as n on n.oid=c.relnamespace where n.nspname='public'::name and c.relname='test'::name and c.relkind='r') is null ) then/*你的代码*/end if;
3.使用information_schema.tables
if( (select 1 from information_schema.tables where table_schema = 'public' and table_name = 'test') is null ) then/*你的代码*/end if;
4.使用pg_tables catalog
if( (select 1 from pg_tables where schemaname = 'public' and tablename = 'test') is null ) then/*你的代码*/end if;
阅读全文
0 0
- PostgreSQL判断表是否存在最快的方法
- Postgresql判断表是否存在
- PostgreSQL判断一个表是否存在
- Postgresql 9.4 判断表是否存在...
- PostgreSQL判断一个表是否存在
- postgresql判断一个表是否存在
- 判断表是否存在的方法
- 判断临时表是否存在的俩方法
- 判断数据库中是否存在表的方法
- sqlite 中判断某个表是否存在的方法
- Oracle判断表、列、主键是否存在的方法
- MySQL中判断表是否存在的方法
- SQL 判断表中是否存在记录的高效率方法
- Sql 判断库、表、存储过程是否存在的方法
- Oracle判断某个表是否存在的方法
- Sqlite中判断表、字段是否存在的方法
- Sqlite中判断表、字段是否存在的方法
- Sqlite中判断表、字段是否存在的方法
- C#中引用C++的dll
- html5变量应用的js最简单的方法
- c语言入门:比较三个数的大小
- centos安装cmake3
- Sigmoid Function
- PostgreSQL判断表是否存在最快的方法
- redis设计与实现(四)字典
- Mathematics
- Java程序性能优化 读书笔记(四)设计模式:享元模式
- 《Spring设计思想》AOP设计基本原理
- tanh Function
- java.lang.IllegalStateException: Failed to load ApplicationContext
- 个人总结20
- 访问者模式