Postgre without a doubt is one of the most popular databases in the market. The reason behind this is PostgreSQL’s speed, security, and robustness. PostgreSQL isn’t just a relational database. PostgreSQL invented many post-relational concepts like in-database functions and user-defined datatypes. Other than that it has many amazing features like Hstore. Now, this blog is for you if you want to know about PostgreSQL Hstore. If you are new to PostgreSQL you can check these blogs to have a basic idea of PostgreSQL https://blog.knoldus.com/lets-get-familiar-with-postgresql-and-its-features/ https://blog.knoldus.com/lets-have-a-look-at-the-postgresql-crud-operation/
What is Hstore in Postgre?
hstore is a data type in PostgreSQL.It helps in implementing data in the form of key-value pairs for a single value. It is useful in scenarios, such as rows with many attributes that are rarely examined, or semi-structured data. Keys and values are simply text strings.
Syntax: variable_name hstore;
To explain this lets take help of an example
Example :- First, we create an employee table with id as the primary key that identifies the employee, the name as the name of the employee, and detail that stores details of the employee such as department, city, and manager_name. The data type of the detail column is the hstore using the below command:
Creating an hStore column
firstly we add some data to our employee table using the below command: