CREATE_ACCESS_METHOD(7pg16)

πŸ“¦ version 16.15, in opensuse-leap 16.0

✨ CREATE ACCESS METHOD ✨

okay bestie, welcome to the CREATE ACCESS METHOD page from the PostgreSQL 16.15 docs β€” manual CREATE ACCESS METHOD(7pg16), section 7, we're in the system-level stuff now and honestly? it's giving power πŸ’…


🌸 NAME 🌸

CREATE ACCESS_METHOD β€” literally the command that defines a brand-new access method. yes, like making one. main character energy fr fr πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

CREATE ACCESS METHOD name
    TYPE access_method_type
    HANDLER handler_function

that's the whole vibe. three lines, no cap πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

so like, CREATE ACCESS METHOD creates a new access method. that's it, that's the whole thing, she said what she said ✨

the access method name has to be unique within the database β€” no duplicates bestie, the database is not a group chat, you can't have two people with the same name πŸ™ˆ

and the big one: only superusers can define new access methods. so if you're not a superuser, this is not your moment, sorry 🫢


πŸ’– PARAMETERS πŸ’–

  • name β€” the name of the access method you're creating. pick something cute, but like, it has to be unique, remember? ⭐
  • access_method_type β€” this clause specifies the type of access method to define. and listen, only TABLE and INDEX are supported at present β€” that's the whole roster, don't come for her with other types πŸ’€
  • handler_function β€” handler_function is the name (possibly schema-qualified πŸ‘€) of a previously registered function that represents the access method. some deets you absolutely cannot skip:
    • the handler function must be declared to take a single argument of type internal πŸ”₯
    • its return type depends on the type of access method: for TABLE access methods it must be table_am_handler, and for INDEX access methods it must be index_am_handler 🌈
    • the C-level API that the handler function must implement varies depending on the type of access method 🧚
    • the table access method API is described in Chapter 63, and the index access method API is described in Chapter 64 β€” go read those if you're actually doing this, iykyk πŸ“š

πŸ¦‹ EXAMPLES πŸ¦‹

creating an index access method called heptree with handler function heptree_handler β€” look at her go πŸ’…

CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler;

ate. no crumbs. ✨


🌺 COMPATIBILITY 🌺

CREATE ACCESS METHOD is a PostgreSQL extension β€” like, it's ours, it's homegrown, not a standard SQL thing πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page bestie, you're officially educated πŸŽ“πŸ’–

ngl the superuser-only thing is the vibe check here β€” if CREATE ACCESS METHOD says no, it means no πŸ™ˆ

✿ sourced straight from the PostgreSQL 16.15 documentation, dated 2026 β€” go off, version girlies 🫢✨

πŸ“¦ where this page comes from