Menu

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.

  1. PostgreSQL Create Databases

    This article describes how to create a new database in PostgreSQL.
  2. PostgreSQL Drop Databases

    Safely remove a PostgreSQL database, avoid current-connection and transaction errors, and handle eligible sessions with PostgreSQL 13+ DROP DATABASE FORCE.
  3. PostgreSQL Alter Databases

    This article describes how to modify a database in PostgreSQL.
  4. PostgreSQL Rename Databases

    This article describes the detailed steps to rename a database in PostgreSQL.
  5. PostgreSQL Create Tables

    This article describes how to create a new table using the CREATE TABLE statement.
  6. PostgreSQL Drop Tables

    This article describes how to use the DROP TABLE statement.
  7. PostgreSQL Alter tables

    This article describes how to use the ALTER TABLE statement to modify an existing table.
  8. PostgreSQL Rename Tables

    This article describes how to rename a table using the ALTER TABLE statement.
  9. PostgreSQL Add Columns

    In this article, you will learn how to add one or more columns to a table using PostgreSQL ALTER TABLE ... ADD COLUMN statements.
  10. PostgreSQL Rename Columns

    In this article, you will learn how to rename one or more columns using PostgreSQL ALTER TABLE ... RENAME COLUMN statements.
  11. PostgreSQL Primary Keys

    In this article, you introduced what a primary key is, its rules, and how to use it in PostgreSQL.
  12. PostgreSQL FOREIGN KEY

    Learn PostgreSQL foreign key rules and syntax, including PostgreSQL 18 PERIOD foreign keys for range coverage.
  13. 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.
  14. PostgreSQL UNIQUE

    Learn PostgreSQL UNIQUE constraints for single and composite keys, NULL handling, NULLS NOT DISTINCT, and how constraints differ from unique indexes.
  15. PostgreSQL Generated Columns

    PostgreSQL 18 supports virtual and stored generated columns. Learn the default behavior, version compatibility, syntax, and expression restrictions.
  16. PostgreSQL Identity Columns

    PostgreSQL identity columns are used to define a column that can automatically generate unique values.
  17. 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.
  18. PostgreSQL CHECK

    Learn PostgreSQL CHECK syntax and fix SQLSTATE 23514 by inspecting the failed row, constraint expression, and existing data.
  19. SERIAL

    Learn how PostgreSQL SMALLSERIAL, SERIAL, and BIGSERIAL use sequences, what constraints they create, how to return generated IDs, and when to use IDENTITY.
  20. PostgreSQL SEQUENCE

    In this article, we covered how to create, use, and drop sequences in PostgreSQL.
  21. PostgreSQL SELECT INTO

    This article describes how to use the SELECT INTO statement create a new table from a result set.
  22. PostgreSQL Schema

    This article discusses the basic usage of PostgreSQL schemas, including creating schemas, modifying schemas, and dropping schemas.