Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

PostgreSQL Insert Record: Insert a record into a table against each column


1. Write a SQL statement to insert a record with your own value into the table countries against each column.

Here in the following is the structure of the table countries.

    Column    |         Type          | Modifiers
--------------+-----------------------+-----------
 country_id   | character varying(2)  |
 country_name | character varying(40) |
 region_id    | numeric(10,0)         |

Sample Solution:

Code:

INSERT INTO countries VALUES('C1','India',1002);

Here is the command to see the list of inserting rows:

postgres=# SELECT * FROM countries;
 country_id | country_name | region_id
------------+--------------+-----------
 C1         | India        |      1002
(1 row)

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: PostgreSQL Insert Records - Exercises, Practice, Solution
Next: Write a SQL statement to insert one row into the table countries against the column country_id and country_name.

What is the difficulty level of this exercise?