CREATE_USER(7pg15)

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

πŸ’… CREATE_USER (7) β€” the PostgreSQL 15.19 manual, bestie edition

okay so you're reading the CREATE USER page from the PostgreSQL 15.19 Documentation and honestly? it's a short one, we love a low-effort icon. let's get into it ✨


πŸŽ€ NAME πŸŽ€

CREATE_USER β€” define a new database role 🫢


✨ SYNOPSIS ✨

CREATE USER name [ [ WITH ] option [ ... ] ]

where option can be:

      SUPERUSER | NOSUPERUSER
    | CREATEDB | NOCREATEDB
    | CREATEROLE | NOCREATEROLE
    | INHERIT | NOINHERIT
    | LOGIN | NOLOGIN
    | REPLICATION | NOREPLICATION
    | BYPASSRLS | NOBYPASSRLS
    | CONNECTION LIMIT connlimit
    | [ ENCRYPTED ] PASSWORD 'password' | PASSWORD NULL
    | VALID UNTIL 'timestamp'
    | IN ROLE role_name [, ...]
    | IN GROUP role_name [, ...]
    | ROLE role_name [, ...]
    | ADMIN role_name [, ...]
    | USER role_name [, ...]
    | SYSID uid

so you give it a name, then optionally say WITH (literally optional, the brackets said so πŸ’β€β™€οΈ) and then yeet in as many options as you want ✨


🌸 the option menu, itemized 🌸

  • SUPERUSER | NOSUPERUSER β€” god mode on / god mode off πŸ‘‘
  • CREATEDB | NOCREATEDB β€” may this role birth new databases or nah
  • CREATEROLE | NOCREATEROLE β€” can it make other roles? main character energy or spectator
  • INHERIT | NOINHERIT β€” inherit privileges or don't, your call
  • LOGIN | NOLOGIN β€” can it actually log in (this one matters, keep reading πŸ‘€)
  • REPLICATION | NOREPLICATION β€” replication powers, yes or no
  • BYPASSRLS | NOBYPASSRLS β€” bypass row-level security, yes or no
  • CONNECTION LIMIT connlimit β€” cap how many connections it gets, connlimit style
  • [ ENCRYPTED ] PASSWORD 'password' | PASSWORD NULL β€” set a password (the ENCRYPTED part is optional), or straight up NULL it πŸ«₯
  • VALID UNTIL 'timestamp' β€” password expires at 'timestamp', Cinderella rules πŸ•›
  • IN ROLE role_name [, ...] β€” drop it into these roles
  • IN GROUP role_name [, ...] β€” same vibe, GROUP spelling
  • ROLE role_name [, ...] β€” make it a member of these roles
  • ADMIN role_name [, ...] β€” give it ADMIN on these roles
  • USER role_name [, ...] β€” another role-listing form, list away
  • SYSID uid β€” takes a uid, that's the tea

πŸ’– DESCRIPTION πŸ’–

okay so here's the plot twist that makes this page so short: CREATE USER is now an alias for CREATE ROLE. that's it. that's the whole difference-adjacent situation.

the only difference β€” and this is the part you need to remember for the quiz πŸ“ β€” is that when the command is spelled CREATE USER, LOGIN is assumed by default. meanwhile, NOLOGIN is assumed when the command is spelled CREATE ROLE.

so like… same command, different default. it's giving twins with different personalities. periodt πŸ’…


🌈 COMPATIBILITY 🌈

the CREATE USER statement is a PostgreSQL extension πŸ¦‹ β€” it's not standard SQL, it's our thing.

the SQL standard leaves the definition of users to the implementation, which is honestly the standard saying "not my problem, figure it out" πŸ’€


πŸ”₯ SEE ALSO πŸ”₯

  • CREATE ROLE (CREATE_ROLE(7)) β€” go read this one too, it's the whole personality this page is cloning ✨

and that's the page, bestie!! πŸŽ€ this was PostgreSQL 15.19, dated 2026 β€” signed, sealed, and delivered from the CREATE USER(7) page itself. no cap, you're now an expert πŸ’œπŸ«Ά

πŸ“¦ where this page comes from