模式删除: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 一定存在于某个地方。
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/10/26/2740932.html,如需转载请自行联系原作者