{"id":801,"date":"2024-12-10T15:31:30","date_gmt":"2024-12-10T08:31:30","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=801"},"modified":"2025-01-03T15:20:25","modified_gmt":"2025-01-03T08:20:25","slug":"postgresql-alter-table","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/","title":{"rendered":"PostgreSQL ALTER TABLE Statement"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: In this tutorial, you will learn how to enhance a table&#8217;s structure using the PostgreSQL <code>ALTER TABLE<\/code> statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='getting-started-with-postgresql-alter-table-statement'>Getting Started with PostgreSQL ALTER TABLE statement <a href=\"#getting-started-with-postgresql-alter-table-statement\" class=\"anchor\" id=\"getting-started-with-postgresql-alter-table-statement\" title=\"Anchor for Getting Started with PostgreSQL ALTER TABLE statement\">#<\/a><\/h2>\n\n\n\n<p>In PostgreSQL, the <code>ALTER TABLE<\/code> statement allows you to modify the table structure effectively.<\/p>\n\n\n\n<p>Here&#8217;s the basic syntax of the <code>ALTER TABLE<\/code> 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\naction;<\/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:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, specify the table name you want to modify the structure.<\/li>\n\n\n\n<li>Second, provide an action you want to perform.<\/li>\n<\/ul>\n\n\n\n<p>Here are the main actions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-rename-table\/\">Renaming a table.<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-rename-column\/\">Rename a column.<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table-add-column\/\">Adding one or more columns to the table.<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-column\/\">Removing a column<\/a>.<\/li>\n\n\n\n<li>Applying a constraint to a column.<\/li>\n\n\n\n<li>Changing the data type of a column.<\/li>\n<\/ul>\n\n\n\n<p>Suppose we have the following <code>materials<\/code> table that stores the product information:<\/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\">TABLE<\/span> materials (\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\">40<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n  status <span class=\"hljs-type\">bool<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>\n);<\/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<h2 class=\"wp-block-heading\" id='renaming-a-table'>Renaming a table <a href=\"#renaming-a-table\" class=\"anchor\" id=\"renaming-a-table\" title=\"Anchor for Renaming a table\">#<\/a><\/h2>\n\n\n\n<p>You use the <code>ALTER TABLE ... RENAME TO<\/code> statement to rename a table:<\/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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">RENAME<\/span> <span class=\"hljs-keyword\">TO<\/span> new_table_name;<\/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>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, specify the name of the table in the <code>ALTER TABLE<\/code> clause.<\/li>\n\n\n\n<li>Second, define the new table name in the <code>RENAME TO<\/code> clause.<\/li>\n<\/ul>\n\n\n\n<p>The following example uses the <code>ALTER TABLE ... RENAME TO<\/code> to rename the <code>materials<\/code> table to <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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> materials\n<span class=\"hljs-keyword\">RENAME<\/span> <span class=\"hljs-keyword\">TO<\/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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgbWF0ZXJpYWxzIFJFTkFNRSBUTyBwcm9kdWN0czs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='renaming-columns'>Renaming columns <a href=\"#renaming-columns\" class=\"anchor\" id=\"renaming-columns\" title=\"Anchor for Renaming columns\">#<\/a><\/h2>\n\n\n\n<p>To rename a column, you use the <code>ALTER TABLE ... RENAME COLUMN<\/code> statement:<\/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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">RENAME<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> <span class=\"hljs-built_in\">column_name<\/span>\n<span class=\"hljs-keyword\">TO<\/span> new_column_name;<\/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>For example, the following example rename the <code>status<\/code> column to <code>active<\/code>:<\/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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">RENAME<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> status\n<span class=\"hljs-keyword\">TO<\/span> active;<\/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<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgUkVOQU1FIENPTFVNTiBzdGF0dXMgVE8gYWN0aXZlOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='adding-new-columns-to-a-table'>Adding new columns to a table <a href=\"#adding-new-columns-to-a-table\" class=\"anchor\" id=\"adding-new-columns-to-a-table\" title=\"Anchor for Adding new columns to a table\">#<\/a><\/h2>\n\n\n\n<p>Use the <code>ALTER TABLE...ADD COLUMN<\/code> statement to add a new column to a table:<\/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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> <span class=\"hljs-built_in\">column_name<\/span> data_type <span class=\"hljs-keyword\">constraint<\/span>;<\/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>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, provide the name of the table you want to modify.<\/li>\n\n\n\n<li>Second, define the column name, type, and constraint in the <code>ADD COLUMN<\/code> clause.<\/li>\n<\/ul>\n\n\n\n<p>For example, the following statement adds the <code>price<\/code> column to the <code>products<\/code> table:<\/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\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> price <span class=\"hljs-type\">DEC<\/span>(<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">2<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgQUREIENPTFVNTiBwcmljZSBERUMoNSwgMikgTk9UIE5VTEw7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>It&#8217;s possible to add multiple columns using the <code>ALTER TABLE<\/code> statement.<\/p>\n\n\n\n<p>For example, the following <code>ALTER TABLE ... ADD COLUMN<\/code> statement adds the <code>weight<\/code>, <code>volume<\/code>, and <code>model_no<\/code> columns to the <code>products<\/code> table:<\/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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> weight <span class=\"hljs-type\">DEC<\/span>(<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">2<\/span>),\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> volume <span class=\"hljs-type\">DEC<\/span>(<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">2<\/span>),\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> model_no <span class=\"hljs-type\">VARCHAR<\/span>(<span class=\"hljs-number\">25<\/span>);<\/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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgQUREIENPTFVNTiB3ZWlnaHQgREVDKDUsIDIpLCBBREQgQ09MVU1OIHZvbHVtZSBERUMoNSwgMiksIEFERCBDT0xVTU4gbW9kZWxfbm8gVkFSQ0hBUigyNSk7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='changing-the-column-data-type'>Changing the column data type <a href=\"#changing-the-column-data-type\" class=\"anchor\" id=\"changing-the-column-data-type\" title=\"Anchor for Changing the column data type\">#<\/a><\/h2>\n\n\n\n<p>You use the <code>ALTER TABLE ... ALTER COLUMN ... SET DATA TYPE<\/code> statement to change the data type of a column:<\/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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> <span class=\"hljs-built_in\">column_name<\/span>\n<span class=\"hljs-keyword\">SET DATA<\/span> <span class=\"hljs-keyword\">TYPE<\/span> new_data_type;<\/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>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, specify the name of the table in the <code>ALTER TABLE<\/code> clause.<\/li>\n\n\n\n<li>Second, provide the name of the column you want to modify.<\/li>\n\n\n\n<li>Third, set the new data type in the <code>SET DATA TYPE<\/code> clause.<\/li>\n<\/ul>\n\n\n\n<p>If the table has data, you must ensure the new type is compatible with the existing data.<\/p>\n\n\n\n<p>For example, the following statement extends the size of the <code>price<\/code> column in the <code>products<\/code> table to <code>DEC(11,2)<\/code>:<\/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-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> price\n<span class=\"hljs-keyword\">SET DATA<\/span> <span class=\"hljs-keyword\">TYPE<\/span> <span class=\"hljs-type\">DEC<\/span>(<span class=\"hljs-number\">11<\/span>, <span class=\"hljs-number\">2<\/span>);<\/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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgQUxURVIgQ09MVU1OIHByaWNlIFNFVCBEQVRBIFRZUEUgREVDKDExLCAyKTs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='applying-constraints-to-columns'>Applying constraints to columns <a href=\"#applying-constraints-to-columns\" class=\"anchor\" id=\"applying-constraints-to-columns\" title=\"Anchor for Applying constraints to columns\">#<\/a><\/h2>\n\n\n\n<p>You use the <code>ALTER TABLE ... ALTER COLUMN SET<\/code> statement to add a constraint to a column.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='not-null-constraint'>NOT NULL constraint <a href=\"#not-null-constraint\" class=\"anchor\" id=\"not-null-constraint\" title=\"Anchor for NOT NULL constraint\">#<\/a><\/h3>\n\n\n\n<p>The following statement applies a <code>NOT NULL<\/code> constraint to a column:<\/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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> <span class=\"hljs-built_in\">column_name<\/span>\n<span class=\"hljs-keyword\">SET<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/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>For example, the following statement adds a <code>NOT NULL<\/code> constraint to the <code>weight<\/code> and <code>volume<\/code> columns of the <code>products<\/code> table:<\/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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> weight <span class=\"hljs-keyword\">SET<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> volume <span class=\"hljs-keyword\">SET<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>;<\/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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgQUxURVIgQ09MVU1OIHdlaWdodCBTRVQgTk9UIE5VTEwsIEFMVEVSIENPTFVNTiB2b2x1bWUgU0VUIE5PVCBOVUxMOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>The weight and column must not have any <code>NULL<\/code> values before you run the statement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='check-constraint'>CHECK constraint <a href=\"#check-constraint\" class=\"anchor\" id=\"check-constraint\" title=\"Anchor for CHECK constraint\">#<\/a><\/h3>\n\n\n\n<p>The following statement adds a <code>CHECK<\/code> constraint to a column:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> <span class=\"hljs-built_in\">column_name<\/span>\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">CHECK<\/span> expression;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><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 following statement adds a <code>CHECK<\/code> constraint to the <code>weight<\/code> and <code>volume<\/code> columns of the <code>products<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">CHECK<\/span> (weight &gt; <span class=\"hljs-number\">0<\/span>),\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">CHECK<\/span> (volume &gt; <span class=\"hljs-number\">0<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgQUREIENIRUNLICh3ZWlnaHQgPiAwKSwgQUREIENIRUNLICh2b2x1bWUgPiAwKTs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='default-constraint'>DEFAULT constraint <a href=\"#default-constraint\" class=\"anchor\" id=\"default-constraint\" title=\"Anchor for DEFAULT constraint\">#<\/a><\/h3>\n\n\n\n<p>The following statement sets a default value for a column using a <code>DEFAULT<\/code> constraint:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> <span class=\"hljs-built_in\">column_name<\/span>\n<span class=\"hljs-keyword\">SET<\/span> <span class=\"hljs-keyword\">DEFAULT<\/span> default_value;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><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>For example, the following statement sets the value for the <code>active<\/code> column to true:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> active\n<span class=\"hljs-keyword\">SET<\/span> <span class=\"hljs-keyword\">DEFAULT<\/span> <span class=\"hljs-keyword\">true<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgQUxURVIgQ09MVU1OIGFjdGl2ZSBTRVQgREVGQVVMVCB0cnVlOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='unique-constraint'>UNIQUE constraint <a href=\"#unique-constraint\" class=\"anchor\" id=\"unique-constraint\" title=\"Anchor for UNIQUE constraint\">#<\/a><\/h3>\n\n\n\n<p>The following statement adds a <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-unique-constraint\/\">unique constraint<\/a> for one or more columns:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">UNIQUE<\/span> (column1, column2, ...);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><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>For example, the following statement adds a unique constraint to the <code>model_no<\/code> of the <code>products<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">ADD<\/span> <span class=\"hljs-keyword\">UNIQUE<\/span> (model_no);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgQUREIFVOSVFVRSAobW9kZWxfbm8pOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='dropping-columns'>Dropping columns <a href=\"#dropping-columns\" class=\"anchor\" id=\"dropping-columns\" title=\"Anchor for Dropping columns\">#<\/a><\/h2>\n\n\n\n<p>The <code>ALTER TABLE ... DROP COLUMN<\/code> removes a column from a table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-20\" 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> <span class=\"hljs-built_in\">column_name<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-20\"><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>For example, the following statement drops the <code>active<\/code> column of the <code>products<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-21\" 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\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products\n<span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">COLUMN<\/span> active;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-21\"><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><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=alterTable&amp;q=QUxURVIgVEFCTEUgcHJvZHVjdHMgRFJPUCBDT0xVTU4gYWN0aXZlOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" 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>Use the <code>ALTER TABLE<\/code> statement to change the structure of a table.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='quiz'>Quiz <a href=\"#quiz\" class=\"anchor\" id=\"quiz\" title=\"Anchor for Quiz\">#<\/a><\/h2>\n\n\n\n<iframe loading=\"lazy\"\n  name=\"quiz\"\n  src=\"\/quiz\/?quiz=alter-table\"\n  height=\"700\"\n  width=\"600\"\n  class=\"iframe\"\n><\/iframe>\n\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=\"801\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL ALTER TABLE Statement\"\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=\"801\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL ALTER TABLE Statement\"\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>In this tutorial, you will learn how to enhance a table&#8217;s structure using the PostgreSQL ALTER TABLE statement.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":13,"menu_order":68,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-801","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 ALTER TABLE Statement<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to use the PostgreSQL ALTER TABLE statement to enhance a table&#039;s structure.\" \/>\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-tutorial\/postgresql-alter-table\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL ALTER TABLE Statement\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to use the PostgreSQL ALTER TABLE statement to enhance a table&#039;s structure.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-03T08:20:25+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-tutorial\\\/postgresql-alter-table\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-alter-table\\\/\",\"name\":\"PostgreSQL ALTER TABLE Statement\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"datePublished\":\"2024-12-10T08:31:30+00:00\",\"dateModified\":\"2025-01-03T08:20:25+00:00\",\"description\":\"In this tutorial, you will learn how to use the PostgreSQL ALTER TABLE statement to enhance a table's structure.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-alter-table\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-alter-table\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-alter-table\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Tutorial\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL ALTER TABLE Statement\"}]},{\"@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 ALTER TABLE Statement","description":"In this tutorial, you will learn how to use the PostgreSQL ALTER TABLE statement to enhance a table's structure.","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-tutorial\/postgresql-alter-table\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL ALTER TABLE Statement","og_description":"In this tutorial, you will learn how to use the PostgreSQL ALTER TABLE statement to enhance a table's structure.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-01-03T08:20:25+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-tutorial\/postgresql-alter-table\/","url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/","name":"PostgreSQL ALTER TABLE Statement","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"datePublished":"2024-12-10T08:31:30+00:00","dateModified":"2025-01-03T08:20:25+00:00","description":"In this tutorial, you will learn how to use the PostgreSQL ALTER TABLE statement to enhance a table's structure.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-alter-table\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Tutorial","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL ALTER TABLE Statement"}]},{"@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\/801","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=801"}],"version-history":[{"count":15,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/801\/revisions"}],"predecessor-version":[{"id":1409,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/801\/revisions\/1409"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/13"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}