Javatpoint Logo

91-9990449935

 0120-4256464

PostgreSQL SELECT Query

In PostgreSQL, the SELECT statement is used to retrieve data from a database table. Data is returned in the form of result table. These result tables are called result-sets.

Syntax:

Here, column1, column2,?..columnN specifies the columns from where you retrieve the data. If you want to retrieve all the fields from the table then you have to use the following syntax:

See this example:

Let's take a table "EMPLOYEES".

postgre select

The above table "EMPLOYEES" has the following records:

postgre select

Follow the steps given below to select a table

  • Select table "EMPLOYEES" and right click on that. You will see an option script, move your cursor over scripts, you will see "SELECT script" option. Click on that.
  • You will get a page like this:
  • postgre select
  • Click on the play button to execute your query. You can arrange the retrieving fields according to your requirement.

Consider that we have to retrieve only "ID" "NAME" and "SALARY" from the table.

Execute the following query:

postgreslq select

Example2:

Execute the following query to retrieve all fields from the table:

OR

Both will give you the same result:

postgre select postgre select
Next TopicPostgreSQL Update