濮阳杆衣贸易有限公司

主頁 > 知識庫 > PostgreSQL 查找當(dāng)前數(shù)據(jù)庫的所有表操作

PostgreSQL 查找當(dāng)前數(shù)據(jù)庫的所有表操作

熱門標(biāo)簽:漯河外呼電話系統(tǒng) 合肥公司外呼系統(tǒng)運(yùn)營商 打電話智能電銷機(jī)器人授權(quán) 美容工作室地圖標(biāo)注 重慶自動外呼系統(tǒng)定制 地圖標(biāo)注和圖片名稱的區(qū)別 辦公外呼電話系統(tǒng) 海豐有多少商家沒有地圖標(biāo)注 外呼調(diào)研系統(tǒng)

實(shí)現(xiàn)的功能類似MySQL:

show tables;

在 PostgreSQL 中需要寫:

select * from pg_tables where schemaname = 'public';

返回結(jié)果類似如下:

schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity 
------------+-----------+------------+------------+------------+----------+-------------+-------------
 public  | deploy | postgres |   | t   | f  | f   | f
 public  | deploy2 | postgres |   | f   | f  | f   | f
(2 rows)

補(bǔ)充:PostgreSql 獲取所有的表、視圖、字段、 主鍵

PostgreSQL獲取數(shù)據(jù)庫中所有view名 視圖:

SELECT viewname FROM pg_views 
WHERE  schemaname ='public' 

postgreSQL獲取數(shù)據(jù)庫中所有table名 表:

SELECT tablename FROM pg_tables 
WHERE tablename NOT LIKE 'pg%' 
AND tablename NOT LIKE 'sql_%'
ORDER BY tablename;

postgreSQL獲取某個表tablename 所有字段名稱 , 類型,備注,是否為空 等

SELECT col_description(a.attrelid,a.attnum) as comment,pg_type.typname as typename,a.attname as name, a.attnotnull as notnull
FROM pg_class as c,pg_attribute as a inner join pg_type on pg_type.oid = a.atttypid
where c.relname = 'tablename' and a.attrelid = c.oid and a.attnum>0

postgreSQL獲取某個表tablename 的主鍵信息

select pg_attribute.attname as colname,pg_type.typname as typename,pg_constraint.conname as pk_name from 
pg_constraint inner join pg_class 
on pg_constraint.conrelid = pg_class.oid 
inner join pg_attribute on pg_attribute.attrelid = pg_class.oid 
and pg_attribute.attnum = pg_constraint.conkey[1]
inner join pg_type on pg_type.oid = pg_attribute.atttypid
where pg_class.relname = 'tablename' 
and pg_constraint.contype='p'

以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。

您可能感興趣的文章:
  • PostgreSQL 自動Vacuum配置方式
  • PHP實(shí)現(xiàn)從PostgreSQL數(shù)據(jù)庫檢索數(shù)據(jù)分頁顯示及根據(jù)條件查找數(shù)據(jù)示例
  • PostgreSQL 如何查找需要收集的vacuum 表信息

標(biāo)簽:錦州 蚌埠 烏海 珠海 衡陽 晉城 來賓 株洲

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PostgreSQL 查找當(dāng)前數(shù)據(jù)庫的所有表操作》,本文關(guān)鍵詞  PostgreSQL,查找,當(dāng)前,數(shù)據(jù)庫,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PostgreSQL 查找當(dāng)前數(shù)據(jù)庫的所有表操作》相關(guān)的同類信息!
  • 本頁收集關(guān)于PostgreSQL 查找當(dāng)前數(shù)據(jù)庫的所有表操作的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    黄大仙区| 石景山区| 恩平市| 新巴尔虎右旗| 合水县| 宁海县| 屏南县| 沈丘县| 礼泉县| 洛川县| 霍邱县| 营口市| 上栗县| 江门市| 比如县| 高邑县| 额敏县| 望奎县| 伊川县| 乌鲁木齐县| 措美县| 海阳市| 招远市| 徐州市| 绥江县| 吴川市| 淄博市| 星座| 罗山县| 桂平市| 衡山县| 达州市| 颍上县| 马龙县| 白玉县| 吉水县| 齐齐哈尔市| 松原市| 巴中市| 神木县| 房产|