PostgreSQL Insert Record: Insert a specific number of rows by a single insert statement
5. Write a SQL statement to insert 3 rows by a single insert statement.
Sample Solution:
Code:
INSERT INTO countries VALUES('C4','India',1001),
('C5','USA',1007),('C6','UK',1003);
Here is the command to see the list of inserting rows :
postgres=# SELECT * FROM countries; country_id | country_name | region_id ------------+--------------+----------- C1 | India | 1002 C2 | USA | C3 | UK | C4 | India | 1001 C5 | USA | 1007 C6 | UK | 1003 (6 rows)
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a SQL statement to insert NULL values into region_id column for a row of countries table.
Next: Write a SQL statement insert rows from the country_new table to countries table.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework