[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com]
模式删除:drop schema 模式名
那么具体对应的源代码是那些呢? src/backend/commands/schemacmds.c
/* * Guts of schema deletion. */ void RemoveSchemaById(Oid schemaOid) { Relation relation; HeapTuple tup; relation = heap_open(NamespaceRelationId, RowExclusiveLock); tup = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(schemaOid)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for namespace %u", schemaOid); simple_heap_delete(relation, &tup->t_self); ReleaseSysCache(tup); heap_close(relation, RowExclusiveLock); }
如果加入调试信息,可以看到,当初创建 schema时得到的 oid, 删除时也是用此oid 来删除。可以说 schema 的oid 一定存在于某个地方。
[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com]