Creating tables
The act of creating tables aims to make logical containers that persistently hold data that belongs together. You will need to create tables for many reasons – for example, tracking employee attendance, revenue tracking, and statistics. The common goal is to provide a service for applications that make sense of it. How do these database engines control who can access what data? There are two approaches:
- The first one is access control lists (ACLs), which is a simple yet powerful approach. ACL security logic tells us which user has which permissions, such as
CREATE
,UPDATE
, andDELETE
. - The second approach involves inheritance and roles. This is more robust and is better suited for big enterprises.
Postgres
uses the second approach, and in this section, we will learn how to create a SQL table and how to create one specifically in Postgres
.
The general syntax for table creation looks like this:
CREATE TABLE table_name ( column1...