PostgreSQL Databases and Tables
Create and alter PostgreSQL databases and tables, then manage columns, keys, constraints, sequences, and transactions.
This chapter introduces the operations related to databases and tables in PostgreSQL, including creating and deleting databases, creating and deleting tables, modifying table columns, primary keys, data constraints, and data types.
-
PostgreSQL Create Databases
This article describes how to create a new database in PostgreSQL. -
PostgreSQL Drop Databases
Safely remove a PostgreSQL database, avoid current-connection and transaction errors, and handle eligible sessions with PostgreSQL 13+ DROP DATABASE FORCE. -
PostgreSQL Alter Databases
This article describes how to modify a database in PostgreSQL. -
PostgreSQL Rename Databases
This article describes the detailed steps to rename a database in PostgreSQL. -
PostgreSQL Create Tables
This article describes how to create a new table using theCREATE TABLEstatement. -
PostgreSQL Drop Tables
This article describes how to use theDROP TABLEstatement. -
PostgreSQL Alter tables
This article describes how to use theALTER TABLEstatement to modify an existing table. -
PostgreSQL Rename Tables
This article describes how to rename a table using theALTER TABLEstatement. -
PostgreSQL Add Columns
In this article, you will learn how to add one or more columns to a table using PostgreSQLALTER TABLE ... ADD COLUMNstatements. -
PostgreSQL Rename Columns
In this article, you will learn how to rename one or more columns using PostgreSQLALTER TABLE ... RENAME COLUMNstatements. -
PostgreSQL Primary Keys
In this article, you introduced what a primary key is, its rules, and how to use it in PostgreSQL. -
PostgreSQL FOREIGN KEY
Learn PostgreSQL foreign key rules and syntax, including PostgreSQL 18 PERIOD foreign keys for range coverage. -
PostgreSQL NOT NULL
Fix PostgreSQL SQLSTATE 23502 by finding explicit or omitted NULL values, choosing a valid default, and preparing existing rows before NOT NULL. -
PostgreSQL UNIQUE
Learn PostgreSQL UNIQUE constraints for single and composite keys, NULL handling, NULLS NOT DISTINCT, and how constraints differ from unique indexes. -
PostgreSQL Generated Columns
PostgreSQL 18 supports virtual and stored generated columns. Learn the default behavior, version compatibility, syntax, and expression restrictions. -
PostgreSQL Identity Columns
PostgreSQL identity columns are used to define a column that can automatically generate unique values. -
Temporal Constraints (PostgreSQL 18)
PostgreSQL 18 adds WITHOUT OVERLAPS keys and PERIOD foreign keys for range data. Learn the syntax, required GiST support, and coverage rules. -
PostgreSQL CHECK
Learn PostgreSQL CHECK syntax and fix SQLSTATE 23514 by inspecting the failed row, constraint expression, and existing data. -
SERIAL
Learn how PostgreSQL SMALLSERIAL, SERIAL, and BIGSERIAL use sequences, what constraints they create, how to return generated IDs, and when to use IDENTITY. -
PostgreSQL SEQUENCE
In this article, we covered how to create, use, and drop sequences in PostgreSQL. -
PostgreSQL SELECT INTO
This article describes how to use theSELECT INTOstatement create a new table from a result set. -
PostgreSQL Schema
This article discusses the basic usage of PostgreSQL schemas, including creating schemas, modifying schemas, and dropping schemas.