DECLARE variable_col int := (SELECT oid FROM pg_class WHERE relname='tablename'); SELECT * FROM pg_class WHERE oid=variable_col; 手头没 pg 库,没执行,大概意思理解一下。 P.S. variable_col 是变量名,我瞎起的;int 记得改成你那个 oid 的数据类型。 有用1 回复 Ocean: 你这个declare的用法...
select*frompg_locks aawhereaa.relationin(selectoidfrompg_classwhererelname='sbtest1'); image.png 查看对应的SQL,发现为 大表之间的left join, 无where条件 (左表600w行, 13GB, 右表1000w行, dn,cn 内存均2GB...) 代码语言:sql 复制 select*frompg_stat_activitywherepidin(selectpidfrompg_locks aa...
db_tapp=# SELECT * , pg_relation_filepath(oid) FROM pg_class where pg_relation_filepath(oid) like '%8843923%'; oid | relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasi...
pg_class.reltype as reltype from pg_attribute ,pg_class,pg_namespace where pg_attribute.attrelid = pg_class.oid and pg_namespace.oid = pg_class.relnamespace and pg_attribute.attnum > 0 and pg_class.relkind = 'r' and pg_namespace.nspname = 'public') as a -- 引号更改成自己的...
sql:select cast(relname as varchar) as Name, cast(obj_description(c.oid,'pg_class') as varchar) as Description from pg_class c inner join pg_namespace n on n.oid = c.relnamespace and nspname='public' inner join pg_tables z on z.tablename=c.relname where relkind in('p', ...
insert into student(id, name,class_id) values(3,'小明',1) on conflict(id) do nothing; ●联合子集更新 # 联合子集更新,把sale_order_line的name连接换行符,然后按id更新到表a_test中对应的name update a_test set name=array_to_string(array(select name from sale_order_line where order_id=a_...
from pg_class c,pg_attribute a where c.relname='表名' and c.oid=a.attrelid and a.attnum>0 四、Mysql版本 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 DROP FUNCTION IF EXISTS f_selectall; DELIMITER $ CREATE FUNCTION f_selectall(ptablename VARCHAR(50),...
select * from pg_extension; 4、查询数据库中的所有表及其描述 select relname as TABLE_NAME ,col_description(c.oid, 0) as COMMENTS from pg_class c where relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%'
SELECT pp.oid as poid, pp.FROM pg_catalog.pg_proc pp WHERE pp.proname ILIKE '%selec%' AND pp.pronamespace IN (2200,11) ORDER BY pp.proname LIMIT 100 SELECT pc.oid,pc.relname,pc.relnamespace,pc.relkind FROM pg_catalog.pg_class pc WHERE pc.relkind in('r','v','m','f','...
如何快速添加这么一个字段: 首先,在这里我们涉及三张系统表,pg_class(表属性)、pg_attribute(列属性)、pg_attrdef(缺省值信息),接下来依次看一下三张表的信息: #pg_class...:oid表系统序列号,relname表名,relnatts列个数(主要修改属性) postgres=# select oid,relname,relnatts from pg_class where relname...