Member-only story
Learning Postgres: Select, Order By, Limit, Offset (Part 6)
When we insert data into tables or change schemas, we also want to see what we have.
Select
The easiest way to see everything is to use this query. It returns all columns from the table.
SELECT * FROM characters;
In PostgreSQL, we can use a shorter query that returns everything, including all columns from the table.
TABLE characters;
Both queries will return the results as below.
Order by
With the previous query, we will retrieve all rows, but they will be in the default order, which can be unpredictable. If we want to see how the results look, we can order the data. For example, if we want data starting from id1, we use ASC
. If we want the latest id first, we use DESC
.
SELECT * FROM characters
ORDER BY id ASC;
Now you can see how it’s nicely ordered from 1 to 11.