CREATE_ACCESS_METHOD(7pg13)

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

πŸ’… CREATE ACCESS METHOD πŸ’…

okay so bestie, quick vibe check: this is the CREATE ACCESS METHOD page from the PostgreSQL 13.23 Documentation, section 7 (that's the SQL commands girlies πŸŽ€). Yes, CREATE ACCESS METHOD(7) β€” the whole manual name, right here, up top, we're not hiding it. Let's get into it ✨


🌸 NAME 🌸

CREATE_ACCESS_METHOD β€” define a new access method. that's it, that's the whole thing, and honestly? iconic of it πŸ’…


✨ SYNOPSIS ✨

CREATE ACCESS METHOD name
    TYPE access_method_type
    HANDLER handler_function

like, look at her. three lines. concise queen πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so CREATE ACCESS METHOD creates a new access method. yep. that's literally what it does, no notes 🌈

the access method name has to be unique within the database β€” no duplicates allowed bestie, the database is NOT sharing names πŸ’€

also, and this is the important part: only superusers can define new access methods. so if you're sitting here like "why is this not working" β€” girl are you a superuser? because if not, it's giving permission denied 😭


πŸŽ€ PARAMETERS πŸŽ€

  • name β€” the name of the access method you're creating. pick something cute, pick something unique, we believe in you 🫢
  • access_method_type β€” this clause specifies the type of access method to define. and at present, only TABLE and INDEX are supported. that's the whole list. two options. that's the menu πŸ“
  • handler_function β€” okay this one's the main character. handler_function is the name (possibly schema-qualified, so like myschema.myfunc bestie, you got options ✨) of a previously registered function that represents the access method. and she has RULES:
    • 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
      • 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 60
      • the index access method API is described in Chapter 61
ngl, this is the part where you actually have to know C. no cap. the handler function is not vibing on its own, it's implementing an API πŸ’€

🌟 EXAMPLES 🌟

create an index access method heptree with handler function heptree_handler β€” here's exactly how, copy her character for character:

CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler;

see? ate. no crumbs πŸ”₯


πŸ’œ COMPATIBILITY πŸ’œ

CREATE ACCESS METHOD is a PostgreSQL extension β€” so it's a Postgres original, not standard SQL, iykyk 🌈✨


🧚 SEE ALSO 🧚

go read those too, they're in the group chat 🫢


PostgreSQL 13.23 Β· 2025 Β· CREATE ACCESS METHOD(7) β€” that's the source, version and date bestie, and this page is officially over. mwah, go define some access methods, ilysm πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from