PostgreSQL Insert for an ObjectRocket Instance
Introduction
The ObjectRocket platform is the futuristic-minded developer’s choice for managing business applications today and in the years to come. One main feature of the platform is its ability to make table management limitations a thing of the past. For example, technical specialists need to organize PostgreSQL data this and that way. And often, the tasks of inserting records is a daily routine. Whether you need to add a single record or multiples, the PostgreSQL insert ObjectRocket statement is a simple operation you’ll want to use on a regular basis. Learn how with this tutorial. Use the INSERT
statement of PostgreSQL for your ObjectRocket instances all of the time.
Prerequisites
Download, install, and configure the latest versions of the following:
PostgreSQL – Version 11 or higher.
Log in to your ObjectRocket account, and from the Mission Control dashboard and create a Postgres instance.
Connecting Local Psql Utility to ObjectRocket Postgres Instance
Make an ObjectRocket Postgres connection for your instance with the psql
local utility for PostgresSQL’s front-end.
After you complete the psql
utility launch, follow the prompts and fill in the required information for your instance of ObjectRocket Postgres.
1 2 3 4 5 6 7 8 9 | Server [localhost]: ingress.w98sujpz.launchpad.objectrocket.cloud DATABASE [PostgreSQL]: Port [5432]: 4149 Username [PostgreSQL]: pguser Password FOR USER orkb: |
An alternative way to make the connection is through the psql
interactive terminal, like this:
1 | psql -h ingress.w98sujpz.launchpad.objectrocket.cloud -U pguser -d PostgreSQL -p 4149 |
Now, use your password to log in:
PostgreSQL INSERT Statement
Add to a table a value set or a single value. Use the statement INSERT
to do the PostgreSQL insert ObjectRocket operation.
In your INSERT
syntax, after table name you put the columns or column list you want to add:
(col1, col2, col3, col4, col5, col6, col7,…colN)
- Add the values or a set of values:
(val1, val2, val3, val4, val5, val6, val7,…valN)
Here is an example of a syntax utilizing the INSERT
statement:
1 2 | INSERT INTO TABLE_NAME (COLUMN OR column_list) VALUES (value_1 OR set_of_values) |
Let’s break down the syntax you used into a more detailed explanation:
Begin with the clause
INSERT INTO
.Input your table’s name.
Add the column names that have the values you want to insert.
Input the values or value set
PostgreSQL Table Structure Example
Create a structured table for practicing the PostgreSQL insert ObjectRocket statement. Within the table, you’ll specify the values and data types.
1 2 3 4 | CREATE TABLE kids_name ( id INT PRIMARY KEY, name VARCHAR ); |
Add the details to the table. Here’s an example of a table all filled out with data you can use for your INSERT
statement.
1 2 3 4 5 6 7 | Table "public.kids_name" Column | Type | Collation | Nullable | Default --------+-------------------+-----------+----------+--------- id | integer | | not null | name | character varying | | | Indexes: "kids_name_pkey" PRIMARY KEY, btree (id) |
PostgreSQL INSERT INTO Table With Single Value Example
Try making a one record insert into the table you created earlier.
Use the INSERT
statement like this:
1 2 | INSERT INTO kids_name (id, name) VALUES (1, 'raizel'); |
You should see a response something similar to this:
1 2 3 4 5 | sandbox=> SELECT * FROM kids_name; id | name ----+-------- 1 | raizel (1 ROW) |
PostgreSQL INSERT INTO Table With Multiple Values Example
You can also perform a multiple-record insert right into your table for PostgreSQL insert ObjectRocket instance.
Use the INSERT
statement like this to add several records:
1 2 3 4 5 6 7 | INSERT INTO kids_name (id, name) VALUES (1, 'yeshua'), (2, 'abishai'), (3, 'abiel'), (4, 'dj'), (5, 'ann'); |
Here are some important things to remember about the INSERT
operation you just completed.
Each value must be separated by a comma.
Immediately after the statement, look for a response that indicates the total of inserted records. In the example, five records were inserted. Therefore, you should receive an
INSERT 0,5
notification which indicates successful completion of the five records you wanted to add to your table.
Confirm it with the statement SELECT
like this:
1 2 3 4 5 6 7 8 9 | sandbox=> SELECT * FROM kids_name; id | name ----+--------- 1 | yeshua 2 | abishai 3 | abiel 4 | dj 5 | ann (5 ROWS) |
Conclusion
PostgreSQL insert ObjectRocket increases productivity because, with the INSERT
statement, you can modify table data in a straightforward way. What’s more, you end up using the least bit of code to get it done. Afterward, you can verify the success of your operation with the SELECT
statement. Doing this decreases the chance for errors. If the number of records you intended to add doesn’t match the number shown in results from the statement SELECT
, you can make any necessary additions with another INSERT
statement. For those professionals like yoursel who manage data all of the time, streamlining the process is always a good thing.
Pilot the ObjectRocket Platform Free!
Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.
Get Started