Loading topic
CREATE TABLE defines a table's structure: its name, its columns, and the type of value each column holds. This chapter covers the statement's syntax, how to run it safely, and the errors you are most likely to hit. Later chapters cover data types and constraints in detail, so the examples here sta5 min readSELECT, INSERT, UPDATE, and DELETE statements. It also assumes you know what tables, rows, and columns are. You should have seen the CREATE TABLE statement from the previous chapter. Examples use PostgreSQL syntax, and dialect differences are noted 5 min readSELECT, INSERT, UPDATE, and DELETE statements. It also assumes you know that a table is made of rows and columns, and that you recognize common data types such as integers, text, and timestamps. The examples use PostgreSQL syntax. Other systems differ5 min readSELECT, INSERT, UPDATE, and DELETE statements. It also assumes you know how CREATE TABLE declares columns and data types. Here you learn what NOT NULL enforces, how it interacts with DEFAULT and other constraints, and which mistakes come up most6 min readINSERT leaves a column out. This chapter assumes you can write basic INSERT and UPDATE statements, know the common data types, and have read the chapter on NOT NULL. It covers the syntax, what counts as a valid default, how defaults interact5 min readINSERT, SELECT and basic CREATE TABLE statements. You should also know what a primary key is. Here you will learn how a database can produce key values for you, how the standard identity syntax works, and where the common systems differ.5 min readUNIQUE constraint tells the database that no two rows may hold the same value in a column, or the same combination of values in a set of columns. This chapter covers how UNIQUE works, how it treats NULL, how it differs from PRIMARY KEY, and the errors you will see when it rejects a statement6 min readSELECT, INSERT, UPDATE, and DELETE statements. It also assumes you know what a primary key and a UNIQUE constraint do, and that you can read a simple CREATE TABLE statement.5 min readCREATE TABLE statement with a PRIMARY KEY and a FOREIGN KEY, and that you know basic INSERT, UPDATE, and DELETE. A foreign key blocks child rows that point to a missing parent. This chapter covers the other direction: what the database does when you d4 min readCREATE TABLE, and how to choose between them. It assumes you can write a basic CREATE TABLE. It also assumes you know what NOT NULL, PRIMARY KEY, UNIQUE, FOREIGN KEY, and CHECK do. The examples use PostgreSQL-style 5 min readCREATE TABLE statement and that you know what PRIMARY KEY, UNIQUE, FOREIGN KEY, and CHECK do. Here you will learn why constraint names matter, how to choose them, and how to use them in error messages and in ALTER TABLE.5 min readCREATE TABLE with the main constraint types (NOT NULL, PRIMARY KEY, UNIQUE, FOREIGN KEY, CHECK). It also assumes you know why constraints should have names. The examples use the customers and orders tables from earlier chapters and PostgreSQL syntax unless a 5 min readCREATE TABLE statements and know what PRIMARY KEY, UNIQUE, and FOREIGN KEY mean. It covers how the database enforces those rules and which indexes it creates or leaves out.5 min readCREATE TABLE with PRIMARY KEY, UNIQUE, FOREIGN KEY, and CHECK, and that you know ho4 min read