{"id":2315,"date":"2025-03-08T22:11:59","date_gmt":"2025-03-08T15:11:59","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=2315"},"modified":"2025-03-08T22:14:02","modified_gmt":"2025-03-08T15:14:02","slug":"postgresql-schema","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/","title":{"rendered":"PostgreSQL Schemas"},"content":{"rendered":"\n<p><strong>Summary:<\/strong>\u00a0In this tutorial, you&#8217;ll learn about PostgreSQL schemas and how to use them to group database objects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction-to-postgresql-schemas\" id='introduction-to-postgresql-schemas'>Introduction to PostgreSQL schemas <a href=\"#introduction-to-postgresql-schemas\" class=\"anchor\" id=\"introduction-to-postgresql-schemas\" title=\"Anchor for Introduction to PostgreSQL schemas\">#<\/a><\/h2>\n\n\n\n<p>A schema is an object inside a database. A schema works like a folder that logically groups database objects like tables, <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-view\/\">views<\/a>, <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-index\/\">indexes<\/a>, <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-sequence\/\">sequences<\/a>, and <a href=\"https:\/\/www.pgtutorial.com\/plpgsql\/plpgsql-functions\/\">functions<\/a>.<\/p>\n\n\n\n<p>A database may have multiple schemas whereas each schema belongs to a specific database.<\/p>\n\n\n\n<p>When you <a href=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-database\/\">create a database<\/a>, PostgreSQL automatically creates a schema called\u00a0<code>public<\/code>. The\u00a0<code>public<\/code>\u00a0schema is the default schema of the database.<\/p>\n\n\n\n<p>If you create any database object like a table without specifying a schema name, PostgreSQL will put that object into the&nbsp;<code>public<\/code>&nbsp;schema.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-schemas\" id='creating-schemas'>Creating schemas <a href=\"#creating-schemas\" class=\"anchor\" id=\"creating-schemas\" title=\"Anchor for Creating schemas\">#<\/a><\/h2>\n\n\n\n<p>PostgreSQL allows you to create a new schema using the&nbsp;<code>CREATE SCHEMA<\/code>&nbsp;statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">SCHEMA<\/span> <span class=\"hljs-built_in\">schema_name<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax, you specify the schema name after the&nbsp;<code>CREATE SCHEMA<\/code>&nbsp;keywords.<\/p>\n\n\n\n<p>For example, the following statement creates a new schema called&nbsp;<code>sales<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">SCHEMA<\/span> sales;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>PostgreSQL lets you create database objects with the same name in different schemas.<\/p>\n\n\n\n<p>For example, if you have a table called\u00a0<code>products<\/code>\u00a0in the\u00a0<code>public<\/code>\u00a0schema, you can <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-create-table\/\">create a new table<\/a> with the same name in the\u00a0<code>sales<\/code>\u00a0schema:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> sales.products(\n    id <span class=\"hljs-type\">INT<\/span> <span class=\"hljs-keyword\">GENERATED<\/span> <span class=\"hljs-keyword\">ALWAYS<\/span> <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-keyword\">IDENTITY<\/span> <span class=\"hljs-keyword\">PRIMARY KEY<\/span>, \n    <span class=\"hljs-type\">name<\/span> <span class=\"hljs-type\">VARCHAR<\/span>(<span class=\"hljs-number\">255<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n    price <span class=\"hljs-type\">DEC<\/span>(<span class=\"hljs-number\">11<\/span>,<span class=\"hljs-number\">2<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To reference&nbsp;<code>products<\/code>&nbsp;in the&nbsp;<code>public<\/code>&nbsp;table, you use&nbsp;<code>products<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> products;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Or<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> <span class=\"hljs-built_in\">public<\/span>.products;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>However, when you reference the&nbsp;<code>products<\/code>&nbsp;table in the&nbsp;<code>sales<\/code>&nbsp;schema, you need to prefix the&nbsp;<code>products<\/code>&nbsp;table with the&nbsp;<code>sales<\/code>&nbsp;schema:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> sales.products;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"schema-search-path\" id='schema-search-path'>Schema search path <a href=\"#schema-search-path\" class=\"anchor\" id=\"schema-search-path\" title=\"Anchor for Schema search path\">#<\/a><\/h2>\n\n\n\n<p>When referencing a table (or any other objects) in a query, you don&#8217;t have to specify the schema name explicitly.<\/p>\n\n\n\n<p>The reason is that PostgreSQL uses the schema search path to determine the order of schemas to find the table.<\/p>\n\n\n\n<p>To check the current search path, you use the&nbsp;<code>SHOW search_path<\/code>&nbsp;statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SHOW<\/span> search_path;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It usually returns the following by default:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"> search_path\n<span class=\"hljs-comment\">--------------<\/span>\n \"$user\", <span class=\"hljs-built_in\">public<\/span>\n(<span class=\"hljs-number\">1<\/span> <span class=\"hljs-keyword\">row<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This means that PostgreSQL first looks for the schema with the same name as the current user (<code>\"$user\"<\/code>). If it cannot find the object, it searches in the&nbsp;<code>public<\/code>&nbsp;schema.<\/p>\n\n\n\n<p>To change the schema search path, you use the&nbsp;<code>SET search_path<\/code>&nbsp;statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SET<\/span> search_path <span class=\"hljs-keyword\">TO<\/span> <span class=\"hljs-built_in\">public<\/span>, sales;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This statement instructs PostgreSQL to search the objects in the&nbsp;<code>public<\/code>&nbsp;schema first and then the&nbsp;<code>sales<\/code>&nbsp;schema.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"listing-all-schemas-in-a-database\" id='listing-all-schemas-in-a-database'>Listing all schemas in a database <a href=\"#listing-all-schemas-in-a-database\" class=\"anchor\" id=\"listing-all-schemas-in-a-database\" title=\"Anchor for Listing all schemas in a database\">#<\/a><\/h2>\n\n\n\n<p>To view all schemas in a database, you use the following query:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-built_in\">schema_name<\/span> \n<span class=\"hljs-keyword\">FROM<\/span> information_schema.schemata;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"> <span class=\"hljs-built_in\">schema_name<\/span>\n<span class=\"hljs-comment\">--------------------<\/span>\n <span class=\"hljs-built_in\">public<\/span>\n sales\n information_schema\n pg_catalog\n pg_toast<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The&nbsp;<code>information_schema<\/code>,&nbsp;<code>pg_catalog<\/code>, and&nbsp;<code>pg_toast<\/code>&nbsp;are system schemas that store metadata.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"granting-privileges-on-a-schema\" id='granting-privileges-on-a-schema'>Granting privileges on a schema <a href=\"#granting-privileges-on-a-schema\" class=\"anchor\" id=\"granting-privileges-on-a-schema\" title=\"Anchor for Granting privileges on a schema\">#<\/a><\/h2>\n\n\n\n<p>First, create a new role called&nbsp;<code>elephant<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">ROLE<\/span> elephant\n<span class=\"hljs-keyword\">WITH<\/span> <span class=\"hljs-keyword\">LOGIN<\/span> <span class=\"hljs-keyword\">PASSWORD<\/span> <span class=\"hljs-string\">'securepassword'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The role&nbsp;<code>elephant<\/code>&nbsp;cannot access the&nbsp;<code>sales<\/code>&nbsp;schema.<\/p>\n\n\n\n<p>Second, <a href=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-grant\/\">grant all privileges<\/a> on the\u00a0<code>sales<\/code>\u00a0schema to the role\u00a0<code>elephant<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">GRANT<\/span> <span class=\"hljs-keyword\">ALL<\/span>\n<span class=\"hljs-keyword\">ON<\/span> <span class=\"hljs-keyword\">SCHEMA<\/span> sales\n<span class=\"hljs-keyword\">TO<\/span> elephant;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Now the role elephant can access the sales schema, create and drop database objects within the sales schema.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"postgresql-schema-applications\" id='applications-of-postgresql-schemas'>Applications of PostgreSQL Schemas <a href=\"#applications-of-postgresql-schemas\" class=\"anchor\" id=\"applications-of-postgresql-schemas\" title=\"Anchor for Applications of PostgreSQL Schemas\">#<\/a><\/h2>\n\n\n\n<p>In application development, you can use schemas to organize, secure, and manage data effectively.<\/p>\n\n\n\n<p>Here are some typical applications of the schemas:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Multi-tenancy applications:<\/strong>\u00a0In software as a service (SaaS) applications, you can create a schema for each tenant (client) within the same database to isolate their data.<\/li>\n\n\n\n<li><strong>Organizing large databases:<\/strong>\u00a0You can use schemas to separate a large database into multiple schemas like sales, finance, and marketing. These schemas help implement more fine-grained security.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"summary\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Schemas are a logical group of database objects within a database.<\/li>\n\n\n\n<li>A database can have multiple schemas, while a schema belongs to a database.<\/li>\n\n\n\n<li>The schema search path determines the order in which schema PostgreSQL searches when executing SQL queries without specifying a schema name.<\/li>\n\n\n\n<li>Use the\u00a0<code>CREATE SCHEMA<\/code>\u00a0statement to create a new schema.<\/li>\n\n\n\n<li>Use the\u00a0<code>GRANT<\/code>\u00a0statement to grant privileges on a schema to a role.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"2315\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL Schemas\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"2315\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL Schemas\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary:\u00a0In this tutorial, you&#8217;ll learn about PostgreSQL schemas and how to use them to group database objects. Introduction to PostgreSQL schemas # A schema is an object inside a database. A schema works like a folder that logically groups database objects like tables, views, indexes, sequences, and functions. A database may have multiple schemas whereas [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2269,"menu_order":6,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2315","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL Schemas<\/title>\n<meta name=\"description\" content=\"In this tutorial, you&#039;ll learn about PostgreSQL schemas and how to use them to group database objects, including tables, views, indexes, etc.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL Schemas\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you&#039;ll learn about PostgreSQL schemas and how to use them to group database objects, including tables, views, indexes, etc.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-08T15:14:02+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-schema\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-schema\\\/\",\"name\":\"PostgreSQL Schemas\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"datePublished\":\"2025-03-08T15:11:59+00:00\",\"dateModified\":\"2025-03-08T15:14:02+00:00\",\"description\":\"In this tutorial, you'll learn about PostgreSQL schemas and how to use them to group database objects, including tables, views, indexes, etc.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-schema\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-schema\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-schema\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Database Administration\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL Schemas\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/\",\"name\":\"PostgreSQL Tutorial\",\"description\":\"Learn PostgreSQL from Scratch\",\"alternateName\":\"PostgreSQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pgtutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL Schemas","description":"In this tutorial, you'll learn about PostgreSQL schemas and how to use them to group database objects, including tables, views, indexes, etc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL Schemas","og_description":"In this tutorial, you'll learn about PostgreSQL schemas and how to use them to group database objects, including tables, views, indexes, etc.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-03-08T15:14:02+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/","url":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/","name":"PostgreSQL Schemas","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"datePublished":"2025-03-08T15:11:59+00:00","dateModified":"2025-03-08T15:14:02+00:00","description":"In this tutorial, you'll learn about PostgreSQL schemas and how to use them to group database objects, including tables, views, indexes, etc.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-schema\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Database Administration","item":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL Schemas"}]},{"@type":"WebSite","@id":"https:\/\/www.pgtutorial.com\/#website","url":"https:\/\/www.pgtutorial.com\/","name":"PostgreSQL Tutorial","description":"Learn PostgreSQL from Scratch","alternateName":"PostgreSQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pgtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/comments?post=2315"}],"version-history":[{"count":5,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2315\/revisions"}],"predecessor-version":[{"id":2320,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2315\/revisions\/2320"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2269"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=2315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}