CREATE_ACCESS_METHOD(7pg14)

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

✨ CREATE ACCESS METHOD ✨

okay so bestie, welcome to CREATE ACCESS METHOD(7) from the PostgreSQL 14.24 docs β€” this is the page where we learn how to literally invent a whole new access method, no cap πŸ’…

🌸 NAME 🌸

CREATE ACCESS METHOD β€” define a new access method

πŸŽ€ SYNOPSIS πŸŽ€

CREATE ACCESS METHOD name
    TYPE access_method_type
    HANDLER handler_function

πŸ¦‹ DESCRIPTION πŸ¦‹

So CREATE ACCESS METHOD creates a brand-new access method. That's the whole vibe ✨

The access method name must be unique within the database β€” no duplicates allowed, periodt. 🚫

And heads up: only superusers can define new access methods. So if you're not a superuser, this is not your main character moment, sorry not sorry 😭

πŸ’– PARAMETERS πŸ’–

  • name β€” the name of the access method to be created. Pick something cute but, like, unique.
  • access_method_type β€” this clause says what kind of access method you're defining. Right now, only TABLE and INDEX are supported. That's it. That's the list. 🫢
  • handler_function β€” the name (possibly schema-qualified, iykyk) of a previously registered function that represents the access method. Real talk about the requirements:
    • 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 also varies depending on the type of access method β€” the table access method API is described in Chapter 61, and the index access method API is described in Chapter 62 πŸ“š

πŸ”₯ EXAMPLES πŸ”₯

Create an index access method heptree with handler function heptree_handler:

CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler;

slay. that's it. that's the example. 🧚

⭐ COMPATIBILITY ⭐

CREATE ACCESS METHOD is a PostgreSQL extension β€” so it's our thing, not a standard-SQL thing πŸ’œ

🌈 SEE ALSO 🌈


and that's the page bestie!! go forth and make access methods πŸ‘‘ this was CREATE ACCESS METHOD(7) from PostgreSQL 14.24, dated 2026 β€” mwah, bye! πŸ’‹πŸŽ€

πŸ“¦ where this page comes from