{"Entry":{"collection":"sql","key":"drop-schema","name":"DROP SCHEMA","aliases":["dropschema"],"metadata":{"aliases":["dropschema"],"changed_in":["8.2"],"changes":[{"from":"7.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"7.3"},{"from":"7.3","purpose_changed":false,"renamed":null,"sections":{"added":["parameters","examples","see_also"],"changed":["description","compatibility"],"removed":["usage"]},"status":"changed","synopsis":null,"to":"7.4"},{"from":"8.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","compatibility"],"removed":[]},"status":"changed","synopsis":{"added":["DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]"],"removed":[]},"to":"8.2"},{"from":"9.5","purpose_changed":false,"renamed":null,"sections":{"added":["notes"],"changed":["description","parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"9.6"},{"from":"11","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"12"},{"from":"16","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"17"},{"from":"18","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"19"}],"content_hash":"047e3357f8a62e5f6b877481736eb96d5e3045cb65eb1a6b9e71f19759f2fe03","derived_content_hash":"ffc6002cce466943dc8282c560a9137f0a14c02c15822d328972f3cbd6ac62da","editorial":{},"first_version":"7.3","group":"schema","imported_at":"2026-09-30T17:43:37.850626+08:00","last_version":"20","name":"DROP SCHEMA","object":"SCHEMA","position":4005,"present_in":["7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"purpose":"remove a schema","purpose_zh":"","related":["alter-schema","create-schema"],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:662f58325383908d4dd0e373d3f8a3b88dffb1ad9c5c074da6f4aaf72247642f","receipt_sha256":"e0cb99fcdbf4bb3fc5a51dcf5786160f244e5220f6620a4a83c4b8c2de529488","repair":"wiki-repair-20261023"},"slug":"drop-schema","source_rev":"wiki-repair-20261023:acdca3f752438af8129b0c81dde59beb6c17e899f22b329ecaf9677980a0b496","synopsis":"DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]","verb":"DROP"}},"Definition":{"Collection":"sql","Key":"drop-schema","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"drop-schema","SourceRevision":"wiki-repair-20261023:acdca3f752438af8129b0c81dde59beb6c17e899f22b329ecaf9677980a0b496","Facts":{"anchor":"SQL-DROPSCHEMA","description_zh":"移除一个模式","description_zh_html":"\u003cpre\u003eDROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eDROP SCHEMA\u003c/code\u003e 从数据库中移除一个或多个模式。\n  \u003c/p\u003e\u003cp\u003e\n   一个模式只能由其拥有者或超级用户删除。注意，即使该模式的拥有者并不拥有模式内的某些对象，也仍然可以删除该模式（从而删除其中的全部对象）。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      如果该模式不存在，则不要抛出错误。这种情况下会发出一个提示。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      模式名称。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eCASCADE\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      自动删除模式中包含的对象（表、函数等），以及进一步依赖于这些对象的所有对象（参见\u003ca class=\"xref\" href=\"/zh/docs/18/ddl-depend.html\" title=\"5.15. 依赖跟踪\"\u003e第 5.15 节\u003c/a\u003e）。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eRESTRICT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      如果该模式中含有任何对象，则拒绝删除它。这是默认值。\n     \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\n   使用 \u003ccode class=\"literal\"\u003eCASCADE\u003c/code\u003e 选项时，该命令除所命名的模式外，还可能删除其他模式中的对象。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e\n   要从数据库中移除模式 \u003ccode class=\"literal\"\u003emystuff\u003c/code\u003e 及其包含的全部内容：\n\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nDROP SCHEMA mystuff CASCADE;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eDROP SCHEMA\u003c/code\u003e 完全符合 SQL 标准，但标准每条命令只允许删除一个模式，另外 \u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e 选项是 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 扩展。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/zh/docs/18/sql-alterschema.html\" title=\"ALTER SCHEMA\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER SCHEMA\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-createschema.html\" title=\"CREATE SCHEMA\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE SCHEMA\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","file":"sql-dropschema.html","lang":"en","name":"DROP SCHEMA","purpose":"remove a schema","purpose_zh":"移除一个模式","related":["alter-schema","create-schema"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP SCHEMA\u003c/code\u003e removes schemas from the database.\u003c/p\u003e\u003cp\u003eA schema can only be dropped by its owner or a superuser. Note that the owner can drop the schema (and thereby all contained objects) even if they do not own some of the objects within the schema.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDo not throw an error if the schema does not exist. A notice is issued in this case.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of a schema.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eCASCADE\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eAutomatically drop objects (tables, functions, etc.) that are contained in the schema, and in turn all objects that depend on those objects (see \u003ca href=\"/docs/18/ddl-depend.html\" title=\"5.15. Dependency Tracking\"\u003eSection 5.15\u003c/a\u003e).\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eRESTRICT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eRefuse to drop the schema if it contains any objects. This is the default.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eUsing the \u003ccode class=\"literal\"\u003eCASCADE\u003c/code\u003e option might make the command remove objects in other schemas besides the one(s) named.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eTo remove schema \u003ccode class=\"literal\"\u003emystuff\u003c/code\u003e from the database, along with everything it contains:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eDROP SCHEMA mystuff CASCADE;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP SCHEMA\u003c/code\u003e is fully conforming with the SQL standard, except that the standard only allows one schema to be dropped per command, and apart from the \u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e option, which is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/alter-schema/?v=18\" title=\"ALTER SCHEMA\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER SCHEMA\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-schema/?v=18\" title=\"CREATE SCHEMA\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE SCHEMA\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"DROP SCHEMA [ IF EXISTS ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [, ...] [ CASCADE | RESTRICT ]","synopsis_text":"DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/sql-dropschema.html","sha256":"570f280748d4da5bb452eba35e3da9713b5f57eb550d608f425988620f7636ee"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-pgdoc"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"drop-schema","SourceDatabase":"center","Version":"18","Locale":"en","Title":"DROP SCHEMA","Summary":"remove a schema","BodyHTML":"\u003cpre\u003eDROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDROP SCHEMA\u003c/code\u003e removes schemas from the database.\u003c/p\u003e\u003cp\u003eA schema can only be dropped by its owner or a superuser. Note that the owner can drop the schema (and thereby all contained objects) even if they do not own some of the objects within the schema.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eParameters\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eIF EXISTS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDo not throw an error if the schema does not exist. A notice is issued in this case.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of a schema.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eCASCADE\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eAutomatically drop objects (tables, functions, etc.) that are contained in the schema, and in turn all objects that depend on those objects (see \u003ca href=\"/docs/18/ddl-depend.html\" rel=\"nofollow\"\u003eSection 5.15\u003c/a\u003e).\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eRESTRICT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eRefuse to drop the schema if it contains any objects. This is the default.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003eUsing the \u003ccode\u003eCASCADE\u003c/code\u003e option might make the command remove objects in other schemas besides the one(s) named.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003eTo remove schema \u003ccode\u003emystuff\u003c/code\u003e from the database, along with everything it contains:\u003c/p\u003e\u003cpre\u003eDROP SCHEMA mystuff CASCADE;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eCompatibility\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDROP SCHEMA\u003c/code\u003e is fully conforming with the SQL standard, except that the standard only allows one schema to be dropped per command, and apart from the \u003ccode\u003eIF EXISTS\u003c/code\u003e option, which is a \u003cspan\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/alter-schema/?v=18\" title=\"ALTER SCHEMA\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER SCHEMA\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-schema/?v=18\" title=\"CREATE SCHEMA\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE SCHEMA\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"wiki-repair-20261023:acdca3f752438af8129b0c81dde59beb6c17e899f22b329ecaf9677980a0b496","ContentHash":"f75291dc89b2e4f2575bb89437d7a8c1aa01db8da20e0b520863b810f3c844ec","Payload":{"related":["alter-schema","create-schema"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP SCHEMA\u003c/code\u003e removes schemas from the database.\u003c/p\u003e\u003cp\u003eA schema can only be dropped by its owner or a superuser. Note that the owner can drop the schema (and thereby all contained objects) even if they do not own some of the objects within the schema.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDo not throw an error if the schema does not exist. A notice is issued in this case.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of a schema.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eCASCADE\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eAutomatically drop objects (tables, functions, etc.) that are contained in the schema, and in turn all objects that depend on those objects (see \u003ca href=\"/docs/18/ddl-depend.html\" title=\"5.15. Dependency Tracking\"\u003eSection 5.15\u003c/a\u003e).\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eRESTRICT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eRefuse to drop the schema if it contains any objects. This is the default.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eUsing the \u003ccode class=\"literal\"\u003eCASCADE\u003c/code\u003e option might make the command remove objects in other schemas besides the one(s) named.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eTo remove schema \u003ccode class=\"literal\"\u003emystuff\u003c/code\u003e from the database, along with everything it contains:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eDROP SCHEMA mystuff CASCADE;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP SCHEMA\u003c/code\u003e is fully conforming with the SQL standard, except that the standard only allows one schema to be dropped per command, and apart from the \u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e option, which is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/alter-schema/?v=18\" title=\"ALTER SCHEMA\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER SCHEMA\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-schema/?v=18\" title=\"CREATE SCHEMA\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE SCHEMA\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","synopsis_html":"DROP SCHEMA [ IF EXISTS ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [, ...] [ CASCADE | RESTRICT ]","synopsis_text":"DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]"}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
