DatabaseLesson 6Free preview
PostgreSQL CREATE TABLE
This lesson is part of PostgreSQL · All levels
Summary
CREATE TABLE is used to define the structure of a new table as a list of columns and its data types. In addition to the data type, you can add constraints like PRIMARY KEY, NOT NULL, UNIQUE, and DEfault to maintain data quality. A well-designed structure from the start makes it easier to develop applications later.
Key points
- CREATE TABLE specifies the name of the table along with a list of columns and types.
- Common data types are: INTEGER, NUMERIC, DATE, BOOLEAN, TIMESTAMP.
- Constraint PRIMARY KEY, NOT NULL, UNIQUE, and DEFAULT maintain the integrity of the data.
- The SERIAL clause makes the id column automatically filled in sequentially.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.