首页 > 代码库 > postgreSQL 一些基础操作

postgreSQL 一些基础操作

获取every_check_accident表中的自增id的最大值

SELECT last_value FROM every_check_accident_id_seq;

 $list = DB::getInstance(self::DBNAME)->pg_insert_id(‘every_check_accident‘,‘id‘);

 

查看postgre的版本

select version();

$list = DB::getInstance(self::DBNAME)->ServerInfo(); # 获取数据库版本

 

锁行 (没测试)

select 1 as adodbignore from $tables where $where for update

$list = DB::getInstance(self::DBNAME)->RowLock($tables,$where);

 

查询库中的所有表名(排除系统目录资料表)

select table_name,‘T‘ from information_schema.tables where table_schema not in ( ‘pg_catalog‘,‘information_schema‘)
union
select table_name,‘V‘ from information_schema.views where table_schema not in ( ‘pg_catalog‘,‘information_schema‘)

$list = DB::getInstance(self::DBNAME)->MetaTables(false, false); 获取所有表名

$list = DB::getInstance(self::DBNAME)->MetaTables(true, true); 获取所有的视图

 

技术分享

 

postgreSQL 一些基础操作