DROP_SERVER(7pg18)
๐ DROP SERVER ๐
okay bestie, so this is the PostgreSQL 18.6 Documentation page for DROP SERVER, and it's genuinely one of the most satisfying little commands ever โ it's giving "spring cleaning but make it SQL". ๐งนโจ
๐ธ NAME ๐ธ
DROP_SERVER โ remove a foreign server descriptor
like. it deletes the descriptor. bye girl. ๐
โจ SYNOPSIS โจ
DROP SERVER [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
look at her. so clean. so structured. the brackets are doing their little optional thing, the | is serving choices. iconique. ๐
๐ฆ DESCRIPTION ๐ฆ
DROP SERVER removes an existing foreign server descriptor. That's the whole assignment, and it ate.
One important little thing though, no cap: to run this command, the current user has to be the owner of the server. So if you're not the owner, this is not your moment. Not your server, not your drop. ๐ซถ
๐ PARAMETERS ๐
IF EXISTSโ bestie this is the "don't be dramatic" flag. If the server doesn't exist, don't throw an error about it. Instead, a notice gets issued. So like, you get told, but nobody's screaming. ๐nameโ the name of an existing server. Yep. That's the one you're dropping. The actual name. Of the server. ๐ธCASCADEโ okay so this one is the "and everything that came with it" energy. It automatically drops objects that depend on the server โ such as user mappings โ and then, in turn, all objects that depend on those objects. It's a whole chain reaction, and you should be aware you're starting it. (see Section 5.15) ๐RESTRICTโ the cautious queen. This one refuses to drop the server if any objects depend on it. And heads up: this is the default. So if you don't say anything, you're gettingRESTRICTwhether you asked for it or not. ๐
ngl if you're unsure, just let RESTRICT do its thing. she's got your back.
๐ฅ EXAMPLES ๐ฅ
Drop a server foo if it exists:
DROP SERVER IF EXISTS foo;
see how chill that is? no error if foo isn't there. just vibes. ๐
๐ COMPATIBILITY ๐
DROP SERVER conforms to ISO/IEC 9075-9 (SQL/MED). So she's standards-compliant, she's legit, she's certified. โจ
But the IF EXISTS clause? That's a PostgreSQL extension. So that bit is Postgres being extra in the best way, iykyk. ๐
๐ SEE ALSO ๐
CREATE SERVER(CREATE_SERVER(7)) โ the one that made the server in the first place ๐ผALTER SERVER(ALTER_SERVER(7)) โ the one that changes it instead of deleting it ๐
๐ fr fr, if you're about to type CASCADE, read that bullet again first. she's powerful and she means it.
and that's the page, bestie!! this was PostgreSQL 18.6, dated 2026, and DROP SERVER(7) will see you next time. slay, stay safe, and always check your dependencies before you cascade. ๐ฆ๐โจ๐๐ธ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms