Chapter 6. Data Definition

Table of Contents

6.1. Table Basics
6.2. Default Values
6.3. Generated Columns
6.4. Constraints
6.4.1. Check Constraints
6.4.2. Not-Null Constraints
6.4.3. Unique Constraints
6.4.4. Primary Keys
6.4.5. Foreign Keys
6.5. System Columns
6.6. Modifying Tables
6.6.1. Adding a Column
6.6.2. Removing a Column
6.6.3. Adding a Constraint
6.6.4. Removing a Constraint
6.6.5. Changing a Column's Default Value
6.6.6. Changing a Column's Data Type
6.6.7. Renaming a Column
6.6.8. Renaming a Table
6.7. Privileges
6.8. Row Security Policies
6.9. Schemas
6.9.1. Creating a Schema
6.9.2. The Public Schema
6.9.3. The Schema Search Path
6.9.4. Schemas and Privileges
6.9.5. The System Catalog Schema
6.9.6. Usage Patterns
6.9.7. Portability
6.10. Inheritance
6.10.1. Caveats
6.11. Table Partitioning
6.11.1. Overview
6.11.2. Declarative Partitioning
6.11.3. Partitioning Using Inheritance
6.11.4. Partition Pruning
6.11.5. Partitioning and Constraint Exclusion
6.11.6. Best Practices for Declarative Partitioning
6.12. Foreign Data
6.13. Other Database Objects
6.14. Dependency Tracking
6.15. LightDB DDL Specification Check

This chapter covers how one creates the database structures that will hold one's data. In a relational database, the raw data is stored in tables, so the majority of this chapter is devoted to explaining how tables are created and modified and what features are available to control what data is stored in the tables. Subsequently, we discuss how tables can be organized into schemas, and how privileges can be assigned to tables. Finally, we will briefly look at other features that affect the data storage, such as inheritance, table partitioning, views, functions, and triggers.