DEV Community

caglarcercinlidev
caglarcercinlidev

Posted on

1 1

CREATE A TABLE ON A POSTGRESQL DATABASE

First some useful commands:

list if databases:
\l

switch to a database:
\c exampledatabase

now it is time to create a table:
CREATE TABLE products (id serial primary key, name varchar (50) not null, price varchar (50) not null);

we have a table but no entries, so:
INSERT INTO products (name, price) VALUES ('hamburger','10');

to check the tables:
\dt

and to see entries on our table:
SELECT * FROM products

wish you an easy coding!

Image description

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay