Skip to content

LANGUAGE

CREATE TABLE employees (
ID INT NOT NULL,
name VARCHAR (20) NOT NULL,
salary FLOAT NOT NULL,
start_date DATE,
city VARCHAR (20),
PRIMARY KEY (ID)
);
INSERT INTO employees (ID, name, salary, start_date, city)
VALUES (1, 'John Doe', 75000, '2022-01-31', 'New York');
SELECT * FROM employees;
ID | name | salary | start_date | city
----|----------|--------|------------|---------
1 | John Doe | 75000 | 2022-01-31 | New York

The example demonstrates the syntax to create a table titled ‘employees’ in PostgreSQL. Following the table’s initialization, one record is inserted using the INSERT INTO statement. The record is then retrieved using the SELECT * FROM employees; query which fetches all records from the employees table. The output shows the returned record in tabulated format.