CREATE_ACCESS_METHOD(7)
CREATE ACCESS METHOD ๐
okay bestie, so this is the PostgreSQL 18.6 manual page for CREATE ACCESS METHOD, living in section 7 of the docs. it's giving "I'm building a whole new way to access data" and honestly? iconic. let's get into it ๐ซถ
โจ NAME โจ
CREATE_ACCESS_METHOD โ bestie, this is how you define a brand new access method. like, from scratch. main character energy fr fr ๐
๐ธ SYNOPSIS ๐ธ
CREATE ACCESS METHOD name
TYPE access_method_type
HANDLER handler_function
that's the whole vibe. three little pieces and you're off ๐ฆ
๐ DESCRIPTION ๐
CREATE ACCESS METHOD creates a new access method. that's it, that's the whole thing, no cap ๐
the access method name has to be unique within the database โ no two methods can share a name, periodt. it's giving "one of one, and I'm not sharing the spotlight" โจ
๐จ superuser check!! only superusers can define new access methods. if you're not one, this is not your moment, and the database will absolutely let you know ๐ญ
๐ PARAMETERS ๐
nameโ the name of the access method you're creating. pick something cute, it's yours now ๐access_method_typeโ this clause says what type of access method you're defining. and bestie, at present onlyTABLEandINDEXare supported. that's the whole guest list, nobody else is getting in ๐handler_functionโhandler_functionis the name (possibly schema-qualified, so you can point at it from anywhere) of a previously registered function that represents the access method. think of it as the little gremlin behind the curtain doing the actual work ๐ง
here's the rules, and they are strict:
- it must be declared to take a single argument of type
internal - its return type depends on the type of access method:
- for
TABLEaccess methods, it must betable_am_handler - for
INDEXaccess methods, it must beindex_am_handler
- for
- the C-level API that the handler function must implement varies depending on the type of access method
and if you want the full tea: the table access method API is described in Chapter 62, and the index access method API is described in Chapter 63. go read those, they're the lore ๐
๐ EXAMPLES ๐
create an index access method called heptree with handler function heptree_handler:
CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler;
ate. no crumbs. ๐ฅ
๐ COMPATIBILITY ๐
CREATE ACCESS METHOD is a PostgreSQL extension โ so ngl, this one's a PostgreSQL original, not a SQL standard situation. iykyk ๐ซ
โญ SEE ALSO โญ
DROP ACCESS METHOD(DROP_ACCESS_METHOD(7)) โ for when it's time to say bye ๐CREATE OPERATOR CLASS(CREATE_OPERATOR_CLASS(7))CREATE OPERATOR FAMILY(CREATE_OPERATOR_FAMILY(7))
go forth and read them all, bestie, they're all connected ๐ซถ
and that's the page!! this was written against PostgreSQL 18.6, dated 2026, and it's literally the CREATE ACCESS METHOD(7) page. slay, stay hydrated, and don't forget to be a superuser first ๐โจ๐
๐ฆ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql 18.6-4 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms